-
Notifications
You must be signed in to change notification settings - Fork 6k
ddl: Non clustered reorg duplicate tidb rowid fix (#60132) #60565
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: Non clustered reorg duplicate tidb rowid fix (#60132) #60565
Conversation
@mjonss This PR has conflicts, I have hold it. |
Signed-off-by: ti-chi-bot <[email protected]>
e7c707f
to
675cb04
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## release-8.5 #60565 +/- ##
================================================
Coverage ? 58.0663%
================================================
Files ? 1770
Lines ? 633214
Branches ? 0
================================================
Hits ? 367684
Misses ? 240978
Partials ? 24552
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
/retest |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mjonss, tangenta 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 |
/retest |
This is an automated cherry-pick of #60132
What problem does this PR solve?
Issue Number: close #59680
Problem Summary:
Issue is that for non-clustered, partitioned tables and REORGANIZE PARTITION (and related alters).
And possibility of EXCHANGE PARTITION, which allows duplicate _tidb_rowid's between partitions.
And the new reorganized set of partitions are not kept in-sync with the old non-reorganized partitions.
What changed and how does it work?
Original issue was #53385. After trying both "Always generate a new _tidb_rowid", (#53770, leading to #57510) and "using AddRecord", to generate new _tidb_rowid's (#57114, leading to #59680) and having the indexes up-to-date (for the currently used set of partition), there will always be issues between the original set of partitions and the reorganized set of partitions, due to not being in sync / having the same _tidb_rowid.
This solution will make sure that if a row exists in both sets of partitions, it will always have the same _tidb_rowid.
It works like this:
During backfill, if a the currents row's tidb_rowid already exists in the new partition:
If same row (content is same as current row)
else
During DML:
Delete: Only delete the reorganized row if it matches both _tidb_rowid AND row content
Update: Use DELETE+INSERT (
RemoveRecord
+AddRecord
) where DELETE is the same as above. When insert/AddRecord
creates a new _tidb_rowid, use that newly generated id for both new and old partitions.And INSERT: if moving between partitions in the current set of partition, then a new unique _tidb_rowid will be generated, so use that the other set of partitions as well. Else if the _tidb_rowid already exists in the other set of partitions, then generate a new _tidb_rowid and use for both sets of partitions.
Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.