-
Notifications
You must be signed in to change notification settings - Fork 6k
ddl: add states to remove old objects during modifying column (#62549) #62777
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
base: release-7.1
Are you sure you want to change the base?
ddl: add states to remove old objects during modifying column (#62549) #62777
Conversation
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
This cherry pick PR is for a release branch and has not yet been approved by triage owners. To merge this cherry pick:
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 kubernetes-sigs/prow repository. |
@tangenta This PR has conflicts, I have hold it. |
@ti-chi-bot: ## If you want to know how to resolve it, please read the guide in TiDB Dev Guide. 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. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@ti-chi-bot: The following tests failed, say
Full PR test history. Your PR dashboard. 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 kubernetes-sigs/prow repository. I understand the commands that are listed here. |
This is an automated cherry-pick of #62549
What problem does this PR solve?
Issue Number: close #60264, close #62531
Problem Summary:
The root cause is that the assumption of "two adjacent schema versions are compatible" is broken for modifying columns covered with indexes:
n-1
. Only old indexes and old columns are visible.n
. Only new indexes are visible.When owner TiDB inserts or deletes a record, only new indexes will be maintained. If you run
SELECT
orADMIN CHECK
on non-owner TiDB with schema versionn-1
, either the data has one more record than the index, or the index has one more record than the data, depending on whether the non-owner node executes an insert or delete statement.This issue doesn't happen on
ADD INDEX
because non-owner TiDBs don't have an "old" index. AnySELECT
statements will useTableScan
instead ofIndexLookup
. There is no such chance to see inconsistent data on non-owner TiDBs.What changed and how does it work?
Before removing public columns/indexes, we should follow the path
public
->write-only
->delete-only
->none
. In the above case, owner TiDB is still aware of the old index (which is inwrite-only
state). As long as it maintains the old index mutations, there is no data inconsistent issue.write-reorg
->public
into multiple steps:write-reorg
, old column & indexespublic
public
, old column & indexeswrite-only
public
, old column & indexesdelete-only
public
, old column & indexesnone
(removed)_Tomestone$_
to represent the objects that need to be removed eventually.Example 1
Example 2
Check List
Tests
Run the script mentioned in Meet "Data is corrupted, missing data for NOT NULL column" when running "delete from xxx" along with DDL (modify column) concurrently #62531 for 20 min, no data inconsistent issue found.
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.