-
Notifications
You must be signed in to change notification settings - Fork 287
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ddl_puller.go(ticdc): fix DDLs are ignored when schema versions are out of order (#11733) #11759
ddl_puller.go(ticdc): fix DDLs are ignored when schema versions are out of order (#11733) #11759
Conversation
This reverts commit 7a4eeef.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files
Flags with carried forward coverage won't be shown. Click here to find out more. @@ Coverage Diff @@
## release-8.1 #11759 +/- ##
================================================
Coverage ? 57.3872%
================================================
Files ? 854
Lines ? 126171
Branches ? 0
================================================
Hits ? 72406
Misses ? 48368
Partials ? 5397 |
/cc @sdojjy @asddongmen |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: lidezhu The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/test cdc-integration-mysql-test |
/test verify |
1 similar comment
/test verify |
This is an automated cherry-pick of #11733
What problem does this PR solve?
Issue Number: close #11714
What is changed and how it works?
Description:
This pull request addresses a bug in TiCDC where a DDL job could be inadvertently dropped if a subsequent DDL job with a higher
SchemaVersion
but lowerCommitTs
is processed first. This behavior occurs because theddlJobPuller
processes DDL jobs based on theirCommitTs
in ascending order and uses a check againstSchemaVersion
that can prevent older DDL jobs from being processed, leading to data inconsistencies.Background:
The issue manifests when two DDL jobs are processed:
ALTER TABLE a ADD COLUMN x, y, z
withCommitTs
400ALTER TABLE b ADD COLUMN y
withCommitTs
300In this scenario, Job 62 is processed first due to its lower
CommitTs
. TheddlJobPuller
then updates itsSchemaVersion
to that of Job 62. When Job 60 is subsequently processed, the current logic discards it because itsSchemaVersion
is deemed older, even though itsCommitTs
is higher.This issue occurs because the
SchemaVersion
increment and job metadata write to TiKV are separate transactions. During a TiDB owner change, different instances might write these transactions without synchronization, leading to potential out-of-orderCommitTs
relative toSchemaVersion
.Solution:
To resolve this, the check on
SchemaVersion
is removed, ensuring that only theCommitTs
is verified:Updated Code:
Reasoning:
The
ResolvedTs
check ensures that only DDL jobs withFinishedTS
greater than the currentResolvedTs
are processed. Since theddlJobPuller
receives DDLs sorted byCommitTs
, any new DDL received with aFinishedTS
greater thanResolvedTs
must be handled, making theSchemaVersion
check redundant.Check List
Tests
Questions
Will it cause performance regression or break compatibility?
No.
Do you need to update user documentation, design documentation or monitoring documentation?
No.
Release note