From 23052ef62342ff5288fed4b2f063eaa45a0e1538 Mon Sep 17 00:00:00 2001 From: Ti Chi Robot Date: Thu, 22 Feb 2024 11:28:57 +0800 Subject: [PATCH] lightning: remove alter table lock (#50074) (#50117) 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 0fbb7f74205c4..b5cd1262fa98b 100644 --- a/br/pkg/lightning/importer/import.go +++ b/br/pkg/lightning/importer/import.go @@ -208,10 +208,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 c1da1972b8c1f..4371dacd1ce29 100644 --- a/br/pkg/lightning/importer/table_import.go +++ b/br/pkg/lightning/importer/table_import.go @@ -896,7 +896,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() { @@ -921,7 +920,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, err