Skip to content

redo(ticdc): add column info for redo ddl event (#12602)#12613

Open
ti-chi-bot wants to merge 1 commit into
pingcap:release-8.5from
ti-chi-bot:cherry-pick-12602-to-release-8.5
Open

redo(ticdc): add column info for redo ddl event (#12602)#12613
ti-chi-bot wants to merge 1 commit into
pingcap:release-8.5from
ti-chi-bot:cherry-pick-12602-to-release-8.5

Conversation

@ti-chi-bot
Copy link
Copy Markdown
Member

This is an automated cherry-pick of #12602

What problem does this PR solve?

Issue Number: close #12600

What is changed and how it works?

Add column info for Redo DDL event to avoid data inconsistency if the column type is time default with origin_default

This PR #12490 will use column info in the DDL event to align the upstream current timestamp. TiCDC has to encode column info for redo ddl event, and redo apply will decode the column info for replicating the ddl event.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Questions

Will it cause performance regression or break compatibility?
Do you need to update user documentation, design documentation or monitoring documentation?

Release note

add column info for redo ddl event

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot ti-chi-bot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. type/cherry-pick-for-release-8.5 This PR is cherry-picked to release-8.5 from a source PR. labels Apr 18, 2026
@ti-chi-bot
Copy link
Copy Markdown
Contributor

ti-chi-bot Bot commented Apr 18, 2026

This cherry pick PR is for a release branch and has not yet been approved by triage owners.
Adding the do-not-merge/cherry-pick-not-approved label.

To merge this cherry pick:

  1. It must be LGTMed and approved by the reviewers firstly.
  2. For pull requests to TiDB-x branches, it must have no failed tests.
  3. AFTER it has lgtm and approved labels, please wait for the cherry-pick merging approval from triage owners.
Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@ti-chi-bot
Copy link
Copy Markdown
Member Author

@wk989898 This PR has conflicts, I have hold it.
Please resolve them or ask others to resolve them, then comment /unhold to remove the hold label.

@ti-chi-bot
Copy link
Copy Markdown
Contributor

ti-chi-bot Bot commented Apr 18, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign leavrth for approval. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot
Copy link
Copy Markdown
Contributor

ti-chi-bot Bot commented Apr 18, 2026

@ti-chi-bot: ## If you want to know how to resolve it, please read the guide in TiDB Dev Guide.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces column metadata to redo DDL events to improve recovery accuracy. Key changes include updating the RedoDDLEvent struct, modifying serialization logic, and enhancing the redo log reader to reconstruct table information. However, several critical issues were identified: the go.mod and go.sum files contain unresolved merge conflicts, and the ToRedoLog implementation fails to populate essential fields like TableName and Type, which will cause data inconsistency during recovery. Additionally, the redo reader uses a hardcoded timestamp for table metadata and employs log.Panic for error handling, which could lead to unnecessary process crashes.

Comment thread go.mod
Comment on lines +96 to +102
<<<<<<< HEAD
github.com/tikv/pd/client v0.0.0-20251219084741-029eb6e7d5d0
github.com/tinylib/msgp v1.1.6
=======
github.com/tikv/pd/client v0.0.0-20260323032024-d7b638033a14
github.com/tinylib/msgp v1.5.0
>>>>>>> 5b45aa084a (redo(ticdc): add column info for redo ddl event (#12602))
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The go.mod file contains unresolved merge conflict markers. This will prevent the project from building and must be resolved before merging.

Comment thread go.sum
Comment on lines +1012 to +1025
<<<<<<< HEAD
github.com/tikv/pd/client v0.0.0-20251219084741-029eb6e7d5d0 h1:fguMZ4sSn/oLbUt+zDoNPd6+OE3Li4Rop2/3vFhu8lM=
github.com/tikv/pd/client v0.0.0-20251219084741-029eb6e7d5d0/go.mod h1:X3T+jK+4bLbDKgupmzvVXuySnCNV4Lfdm/bL8TAw3ik=
github.com/tinylib/msgp v1.1.6 h1:i+SbKraHhnrf9M5MYmvQhFnbLhAXSDWF8WWsuyRdocw=
github.com/tinylib/msgp v1.1.6/go.mod h1:75BAfg2hauQhs3qedfdDZmWAPcFMAvJE5b9rGOMufyw=
=======
github.com/tikv/pd/client v0.0.0-20260323032024-d7b638033a14 h1:TVSx20m6DZMSiI37Dduu9RZb8yUvT1sgW8kCLAe+T5U=
github.com/tikv/pd/client v0.0.0-20260323032024-d7b638033a14/go.mod h1:4kxXuAQAREpH+lVbydVwGNNDmcwdj0RG4Ofwky08W/k=
github.com/tinylib/msgp v1.5.0 h1:GWnqAE54wmnlFazjq2+vgr736Akg58iiHImh+kPY2pc=
github.com/tinylib/msgp v1.5.0/go.mod h1:cvjFkb4RiC8qSBOPMGPSzSAx47nAsfhLVTCZZNuHv5o=
github.com/tjfoc/gmsm v1.3.2/go.mod h1:HaUcFuY0auTiaHB9MHFGCPx5IaLhTUd2atbCFBQXn9w=
github.com/tjfoc/gmsm v1.4.1 h1:aMe1GlZb+0bLjn+cKTPEvvn9oUEBlJitaZiiBwsbgho=
github.com/tjfoc/gmsm v1.4.1/go.mod h1:j4INPkHWMrhJb38G+J6W4Tw0AbuN8Thu3PbdVYhVcTE=
>>>>>>> 5b45aa084a (redo(ticdc): add column info for redo ddl event (#12602))
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The go.sum file contains unresolved merge conflict markers at multiple locations (e.g., lines 1012-1025 and 1384-1388). These must be resolved to ensure dependency integrity.

Comment thread cdc/model/sink.go
Comment on lines +326 to 341
var columns []*ColumnInfo
if d.TableInfo != nil && d.TableInfo.TableInfo != nil {
columns = make([]*ColumnInfo, 0, len(d.TableInfo.Columns))
for _, col := range d.TableInfo.Columns {
columns = append(columns, &ColumnInfo{
Name: col.Name.String(),
OriginDefaultValue: col.GetOriginDefaultValue(),
Type: col.GetType(),
Version: col.Version,
})
}
}
return &RedoLog{
RedoDDL: RedoDDLEvent{DDL: d},
RedoDDL: RedoDDLEvent{DDL: d, Columns: columns},
Type: RedoLogTypeDDL,
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The ToRedoLog function fails to populate the TableName and Type fields in the RedoDDLEvent struct. These fields are essential for the redo log reader to correctly reconstruct the table metadata during recovery. Without them, the reader will receive empty table names and default types, which could lead to data inconsistency or errors during DDL application.

	var columns []*ColumnInfo
	var tableName TableName
	if d.TableInfo != nil {
		tableName = d.TableInfo.TableName
		if d.TableInfo.TableInfo != nil {
			columns = make([]*ColumnInfo, 0, len(d.TableInfo.Columns))
			for _, col := range d.TableInfo.Columns {
				columns = append(columns, &ColumnInfo{
					Name:               col.Name.String(),
					OriginDefaultValue: col.GetOriginDefaultValue(),
					Type:               col.GetType(),
					Version:            col.Version,
				})
			}
		}
	}
	return &RedoLog{
		RedoDDL: RedoDDLEvent{
			DDL:       d,
			Columns:   columns,
			TableName: tableName,
			Type:      d.Type,
		},
		Type: RedoLogTypeDDL,
	}

Comment thread cdc/redo/reader/reader.go
}
columns = append(columns, colInfo)
}
return model.WrapTableInfo(0, ddl.TableName.Schema, 100, &timodel.TableInfo{
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The UpdateTS (third argument to WrapTableInfo) is hardcoded to 100. It is more appropriate to use the CommitTs from the DDL event to ensure the reconstructed metadata reflects the correct point in time.

Suggested change
return model.WrapTableInfo(0, ddl.TableName.Schema, 100, &timodel.TableInfo{
return model.WrapTableInfo(0, ddl.TableName.Schema, ddl.DDL.CommitTs, &timodel.TableInfo{

Comment thread cdc/redo/reader/reader.go
Comment on lines +412 to +416
log.Panic("set origin default value failed",
zap.String("column", col.Name),
zap.Any("originDefaultValue", col.OriginDefaultValue),
zap.Error(err))
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using log.Panic here will crash the entire TiCDC process if a DDL event in the redo log has an invalid default value. Consider returning an error instead to allow the system to handle the failure more gracefully (e.g., by stopping the specific replication task instead of the whole process).

@ti-chi-bot
Copy link
Copy Markdown
Contributor

ti-chi-bot Bot commented Apr 18, 2026

@ti-chi-bot: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-build-8.5 08c1988 link true /test pull-build-8.5
pull-check-8.5 08c1988 link true /test pull-check-8.5
pull-unit-test-cdc-8.5 08c1988 link true /test pull-unit-test-cdc-8.5
pull-dm-integration-test 08c1988 link true /test pull-dm-integration-test
pull-cdc-integration-storage-test 08c1988 link true /test pull-cdc-integration-storage-test
pull-cdc-integration-pulsar-test 08c1988 link true /test pull-cdc-integration-pulsar-test
pull-cdc-integration-kafka-test 08c1988 link true /test pull-cdc-integration-kafka-test
pull-cdc-integration-mysql-test 08c1988 link true /test pull-cdc-integration-mysql-test
pull-verify 08c1988 link true /test pull-verify
pull-syncdiff-integration-test 08c1988 link true /test pull-syncdiff-integration-test
pull-dm-compatibility-test 08c1988 link true /test pull-dm-compatibility-test

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge/cherry-pick-not-approved do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. type/cherry-pick-for-release-8.5 This PR is cherry-picked to release-8.5 from a source PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants