-
Notifications
You must be signed in to change notification settings - Fork 409
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: Fix database drop by accident when meet regenerate_schema_map
flag
#8785
ddl: Fix database drop by accident when meet regenerate_schema_map
flag
#8785
Conversation
regenerate_schema_map
flagregenerate_schema_map
flag
Though The actions that make a SchemaDiff with |
/run-all-tests |
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
Does this mean when meets diff->regenerate_schema_map = true
, all databases in Database info cache will be dropped in previous implement?
Yes. The v7.1 and oldest versions implement it correctly. The implementation in current master/7.5 branch is a mistake after DDL framework refactor since v7.2. codes in v7.1: tiflash/dbms/src/TiDB/Schema/SchemaBuilder.cpp Lines 1361 to 1470 in b7b6d00
|
/run-integration-test |
/run-integration-test |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: JinheLin, Lloyd-Pottiger 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:
|
In response to a cherrypick label: failed to apply #8785 on top of branch "release-7.5":
|
What problem does this PR solve?
Issue Number: close #8777
Problem Summary:
Normally, after users executed DDL statements, the TiDB server will generate some "SchemaDiff" to indicate what happens. And TiFlash will follow the "SchemaDiff" to figure out what DDL operations need to be executed.
But when there are special DDL
FLASHBACK CLUSTER TO
orbr restore point
(which generateregenerate_schema_map == true
), TiFlash will try to list all existing databases and tables in the cluster and entersyncAllSchema
to check all existing databases and tables one by one and execute proper DDL on them.However, in the DDL framwork refactor since v7.2(#7437), there is a mistake in the implementation. In the following codes, only newly created database that does not exist in TiFlash local are put in
created_db_set
. In line 1383, if the database is not existed increated_db_set
, then the database will be marked as tombstone unexpectedly. And after the gc_safepoint advance, the data on TiFlash replica get physically removed unexpectedly. :(tiflash/dbms/src/TiDB/Schema/SchemaBuilder.cpp
Lines 1269 to 1391 in fe6621b
Though
syncAllSchema
will also run right after TiFlash restarts, but at that time, theDatabaseInfoCache
is empty, so it do not trigger this bug.What is changed and how it works?
Add the database name to set no matter the database is already present locally or not
Check List
Tests
Side effects
Documentation
Release note