From af930be82f048fc5735ce40882450b18f52992a4 Mon Sep 17 00:00:00 2001 From: tiancaiamao Date: Wed, 6 Nov 2024 23:02:50 +0800 Subject: [PATCH] *: fix resource leak in select for update when 'tidb_low_resolution_tso' is set (#57012) close pingcap/tidb#55468 --- pkg/executor/adapter.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/executor/adapter.go b/pkg/executor/adapter.go index cd1f3affea5c6..431efd09da0c6 100644 --- a/pkg/executor/adapter.go +++ b/pkg/executor/adapter.go @@ -598,6 +598,7 @@ func (a *ExecStmt) Exec(ctx context.Context) (_ sqlexec.RecordSet, err error) { if a.isSelectForUpdate { if sctx.GetSessionVars().UseLowResolutionTSO() { + terror.Log(exec.Close(e)) return nil, errors.New("can not execute select for update statement when 'tidb_low_resolution_tso' is set") } // Special handle for "select for update statement" in pessimistic transaction. @@ -614,6 +615,7 @@ func (a *ExecStmt) Exec(ctx context.Context) (_ sqlexec.RecordSet, err error) { var txnStartTS uint64 txn, err := sctx.Txn(false) if err != nil { + terror.Log(exec.Close(e)) return nil, err } if txn.Valid() {