-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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: check the key existence on original index (#40749) #41271
ddl: check the key existence on original index (#40749) #41271
Conversation
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
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.
LGTM
/merge |
This pull request has been accepted and is ready to merge. Commit hash: 6e3523a
|
/run-check_dev |
/retest |
This is an automated cherry-pick of #40749
What problem does this PR solve?
Issue Number: close #40730
Problem Summary:
The problem happens on the unique check. A deletion marker on temporary index doesn't mean the corresponding row record is deleted.
What is changed and how it works?
Because the last DML in above issue happens in the final stage of adding index, there is no way to "detect" duplicated keys after the insertion. In other words, this DML must report a key duplicated error. Thus, we have to correct the key uniqueness check mechanism when TiDB writes to temp index. This is also crucial to DML like
REPLACE
andINSERT ON DUPLICATE UPDATE
because the uniqueness determines the semantic of the following action.Here is the new uniqueness check introduced in this PR:
The second change is about the encoding of temp index value.
When there are multiple insertions or deletions to the temp index, TiDB always overwrites the previous value in current implementation. This may cause some of the user changes lost and data-index inconsistency. Several test cases in this PR show the problems.
This PR introduces a new temp index value encoding, storing all the insertion/deletion history by appending new value to existing value. In the merge process, the temp index merge worker extracts the operations in temp index value, and replay them to the index.
Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.