-
Notifications
You must be signed in to change notification settings - Fork 5.9k
ddl: Non clustered reorg duplicate tidb rowid fix #60132
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
Conversation
…part-backfill-dml-58226
TODO: Still check issues with new _tidb_rowid's when it comes to INDEX as well as updating both new+old set of partition as well as old+new...
…g-duplicate-_tidb_rowid-fix
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Defined2014, 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 |
[LGTM Timeline notifier]Timeline:
|
Signed-off-by: ti-chi-bot <[email protected]>
In response to a cherrypick label: new pull request created to branch |
/cherry-pick release-8.5 |
@bb7133: new pull request could not be created: failed to create pull request against pingcap/tidb#release-8.5 from head ti-chi-bot:cherry-pick-60132-to-release-8.5: status code 422 not one of [201], body: {"message":"Validation Failed","errors":[{"resource":"PullRequest","code":"custom","message":"A pull request already exists for ti-chi-bot:cherry-pick-60132-to-release-8.5."}],"documentation_url":"https://docs.github.com/rest/pulls/pulls#create-a-pull-request","status":"422"} In response to this:
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. |
Signed-off-by: ti-chi-bot <[email protected]>
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.