-
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
ddl_puller.go(ticdc): fix DDLs are ignored when schema versions are out of order #11733
Conversation
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 @@
## master #11733 +/- ##
================================================
+ Coverage 55.1522% 55.1547% +0.0025%
================================================
Files 1001 1002 +1
Lines 136524 137397 +873
================================================
+ Hits 75296 75781 +485
- Misses 55718 56065 +347
- Partials 5510 5551 +41 |
/retest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add some unit test to cover this ?
This issue is difficult to reproduce and occurs in rare cases, making it hard to mock. |
/hold |
/unhold |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: asddongmen, 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 |
[LGTM Timeline notifier]Timeline:
|
This reverts commit 7a4eeef.
/retest |
In response to a cherrypick label: new pull request created to branch |
In response to a cherrypick label: new pull request created to branch |
Signed-off-by: ti-chi-bot <[email protected]>
In response to a cherrypick label: new pull request created to branch |
Signed-off-by: ti-chi-bot <[email protected]>
Signed-off-by: ti-chi-bot <[email protected]>
In response to a cherrypick label: new pull request created to branch |
In response to a cherrypick label: new pull request created to branch |
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