ddl: don't delay for async commit if MDL is enabled (#39446)

ref pingcap/tidb#39196
This commit is contained in:
wjHuang
2022-11-30 20:32:01 +08:00
committed by GitHub
parent 63ce7931b0
commit d20d71f911

View File

@ -1329,6 +1329,12 @@ type RecoverSchemaInfo struct {
// It should be called before any DDL that could break data consistency.
// This provides a safe window for async commit and 1PC to commit with an old schema.
func delayForAsyncCommit() {
if variable.EnableMDL.Load() {
// If metadata lock is enabled. The transaction of DDL must begin after prewrite of the async commit transaction,
// then the commit ts of DDL must be greater than the async commit transaction. In this case, the corresponding schema of the async commit transaction
// is correct. But if metadata lock is disabled, we can't ensure that the corresponding schema of the async commit transaction isn't change.
return
}
cfg := config.GetGlobalConfig().TiKVClient.AsyncCommit
duration := cfg.SafeWindow + cfg.AllowedClockDrift
logutil.BgLogger().Info("sleep before DDL finishes to make async commit and 1PC safe",