From ac771df2d89c42f3e55bd07418c33f15256e5899 Mon Sep 17 00:00:00 2001 From: D3Hunter Date: Fri, 5 Jan 2024 13:47:17 +0800 Subject: [PATCH] lightning: remove alter table lock (#50074) close pingcap/tidb#50105 --- br/pkg/lightning/importer/import.go | 7 +++---- br/pkg/lightning/importer/table_import.go | 2 -- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/br/pkg/lightning/importer/import.go b/br/pkg/lightning/importer/import.go index 75acf5235be49..26b07acaadf43 100644 --- a/br/pkg/lightning/importer/import.go +++ b/br/pkg/lightning/importer/import.go @@ -206,10 +206,9 @@ type Controller struct { db *sql.DB pdCli pd.Client - alterTableLock sync.Mutex - sysVars map[string]string - tls *common.TLS - checkTemplate Template + sysVars map[string]string + tls *common.TLS + checkTemplate Template errorSummaries errorSummaries diff --git a/br/pkg/lightning/importer/table_import.go b/br/pkg/lightning/importer/table_import.go index 6bb8cc42c03a8..469f1360cec06 100644 --- a/br/pkg/lightning/importer/table_import.go +++ b/br/pkg/lightning/importer/table_import.go @@ -951,7 +951,6 @@ func (tr *TableImporter) postProcess( // alter table set auto_increment if cp.Status < checkpoints.CheckpointStatusAlteredAutoInc { - rc.alterTableLock.Lock() tblInfo := tr.tableInfo.Core var err error if tblInfo.ContainsAutoRandomBits() { @@ -976,7 +975,6 @@ func (tr *TableImporter) postProcess( err = common.RebaseGlobalAutoID(ctx, adjustIDBase(newBase), tr, tr.dbInfo.ID, tr.tableInfo.Core) } } - rc.alterTableLock.Unlock() saveCpErr := rc.saveStatusCheckpoint(ctx, tr.tableName, checkpoints.WholeTableEngineID, err, checkpoints.CheckpointStatusAlteredAutoInc) if err = firstErr(err, saveCpErr); err != nil { return false, errors.Trace(err)