ddl: Fix unstable DROP TABLE
/FLASHBACK TABLE
/RECOVER TABLE
(#8422)
#8443
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is an automated cherry-pick of #8422
What problem does this PR solve?
Issue Number: close #8395, close #1664, close #3777
Problem Summary:
Problem 1:
There could be a chance that raft snapshot or raft command of a table comes after it has been dropped.
Because tiflash will ignore the previous
DROP TABLE
, because storage instance is not created yet. The storage instance is created as "non tombstone" after that when raft snapshot or raft command comes. And the storage instance will never be physically dropped until tiflash restarts.Problem 2:
In the second time when
syncTableSchema
callstrySyncTableSchema
after table-id-mapping is up-to-date, it should usemvcc get
to ensure it can use the table schema of tombstone table to create Storage instance or decode new raft logs, or some new columns data will not be decoded.Previously
updateTiFlashReplica
will update the table info with the latest columns by accident. So tiflash pass the related tests sometimes.What is changed and how it works?
This is a PR following #8421
The logic changes is these commits: https://github.com/pingcap/tiflash/pull/8422/files/d88f6b6f4ae4c8026b969cd9c5ae50924b179529..1fe991997055f755aea89cd2e2bdb8ab26a848bf
syncTableSchema
callstrySyncTableSchema
, it will not usemvcc get
so that we can detect whether we need to update the table-id-mappingsyncTableSchema
callstrySyncTableSchema
after table-id-mapping is up-to-date, it will usemvcc get
to ensure it can use the table schema of tombstone table to create Storage instance or decode new raft logs.SchemaGetter::getTableInfoImpl
does not check the existence ofdb_key
, so that we can still get the table info after database is dropped. (get ready forFLASHBACK DATABASE ... TO ...
)client-c mvcc get
, then we will create the storage instance with a tombstone timestamp. So that it can be physically dropped after GC time.applySetTiFlashReplica
should only update the tiflash replica info instead of replacing all the table info, or it will lead to some later DDLs (changing partitions, etc) is not executedrecover table
codes using early returnCheck List
Tests
Side effects
Documentation
Release note