-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
*: redirect the DML writes to a temp index during creating index #37709
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. |
Co-authored-by: wjHuang <huangwenjun1997@gmail.com>
Co-authored-by: wjHuang <huangwenjun1997@gmail.com>
Co-authored-by: wjHuang <huangwenjun1997@gmail.com>
Co-authored-by: wjHuang <huangwenjun1997@gmail.com>
Co-authored-by: wjHuang <huangwenjun1997@gmail.com>
Co-authored-by: Lynn <zimu_xia@126.com>
Co-authored-by: Lynn <zimu_xia@126.com>
Co-authored-by: xiongjiwei <xiongjiwei1996@outlook.com>
Co-authored-by: xiongjiwei <xiongjiwei1996@outlook.com>
Co-authored-by: Lynn <zimu_xia@126.com>
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
@Benjamin2037: Thanks for your review. The bot only counts approvals from reviewers and higher roles in list, but you're still welcome to leave your comments. 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. |
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: ead1325
|
TiDB MergeCI notify🔴 Bad News! New failing [1] after this pr merged.
|
What problem does this PR solve?
Issue Number: ref #35983
Problem summary:
Previously, the new index records backfill are done by a reorg worker with multiple transactions (DDL txn). When the index schema state has entered
delete-only
/write-only
, according to the online schema change, the DML (DELETE
/INSERT
/UPDATE
) statements can write new records the index (DML txn).If the same keys are written in both DDL txn and DML txn, one of them will be rollbacked because of the write conflict. This could make either the create-index DDL inefficient or introduce high latency to the DML.
What is changed and how it works?
The old implementation:
This PR provides a new index creating process. We can redirect the DML txn writes to a temporary index once the creating index's schema state has entered
delete-only
:Because the index IDs are different, no write conflicts can happen. After the DDL txns finished, it requires a new txn to merge the temp index record to the origin index.
Thus, the whole add index process needs to reorganize the data twice. To control the progress and make sure the data consistency, here we introduce the new field
BackfillState
tomodel.IndexInfo
. It contains the following values:The tuple (
SchemaState
,BackfillState
) reflects the current status of creating index.As a result, the index's schema state changes are as follows:
There are also changes for GC-delete range: before this PR,
ADD INDEX
jobs only insert the index ID togc_delete_range
table if it is rollbacked or cancelled. After this PR, we always insert the temporary index ID togc_delete_range
because TiDB could fallback to the old backfill process in extreme cases.Note that the DML writes to temporary index are handled specially. For example, delete operations are converted to writes like
key -> "delete"
. In the merging stage, TiDB convert these special records back to delete operations.Check List
Tests
set global tidb_ddl_enable_fast_reorg = on;
.Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.