From e0e8f89336e442e9cf6aa002469d291d075ace47 Mon Sep 17 00:00:00 2001 From: lance6716 Date: Fri, 26 Jul 2024 16:42:46 +0800 Subject: [PATCH] lightning: fix SET SESSION on connection pool (#54927) close pingcap/tidb#49826 --- lightning/pkg/importer/meta_manager.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lightning/pkg/importer/meta_manager.go b/lightning/pkg/importer/meta_manager.go index 188ecb9987507..d4fe9523b08e4 100644 --- a/lightning/pkg/importer/meta_manager.go +++ b/lightning/pkg/importer/meta_manager.go @@ -185,7 +185,7 @@ func (m *dbTableMetaMgr) AllocTableRowIDs(ctx context.Context, rawRowIDMax int64 //nolint: errcheck defer conn.Close() exec := &common.SQLWithRetry{ - DB: m.session, + DB: conn, Logger: m.tr.logger, } var newRowIDBase, newRowIDMax int64 @@ -391,7 +391,7 @@ func (m *dbTableMetaMgr) CheckAndUpdateLocalChecksum(ctx context.Context, checks //nolint: errcheck defer conn.Close() exec := &common.SQLWithRetry{ - DB: m.session, + DB: conn, Logger: m.tr.logger, } err = exec.Exec(ctx, "enable pessimistic transaction", "SET SESSION tidb_txn_mode = 'pessimistic';") @@ -664,7 +664,7 @@ func (m *dbTaskMetaMgr) CheckTasksExclusively(ctx context.Context, action func(t //nolint: errcheck defer conn.Close() exec := &common.SQLWithRetry{ - DB: m.session, + DB: conn, Logger: log.FromContext(ctx), } err = exec.Exec(ctx, "enable pessimistic transaction", "SET SESSION tidb_txn_mode = 'pessimistic';") @@ -735,7 +735,7 @@ func (m *dbTaskMetaMgr) CheckAndPausePdSchedulers(ctx context.Context) (pdutil.U //nolint: errcheck defer conn.Close() exec := &common.SQLWithRetry{ - DB: m.session, + DB: conn, Logger: log.FromContext(ctx), } err = exec.Exec(ctx, "enable pessimistic transaction", "SET SESSION tidb_txn_mode = 'pessimistic';") @@ -875,7 +875,7 @@ func (m *dbTaskMetaMgr) CheckAndFinishRestore(ctx context.Context, finished bool //nolint: errcheck defer conn.Close() exec := &common.SQLWithRetry{ - DB: m.session, + DB: conn, Logger: log.FromContext(ctx), } err = exec.Exec(ctx, "enable pessimistic transaction", "SET SESSION tidb_txn_mode = 'pessimistic';")