From e31c3c853f87475d5801b73912f04b635026a08a Mon Sep 17 00:00:00 2001 From: tiancaiamao Date: Thu, 31 Oct 2024 03:30:13 +0800 Subject: [PATCH 1/2] *: fix resource leak in select for update when 'tidb_low_resolution_tso' is set --- pkg/executor/adapter.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/executor/adapter.go b/pkg/executor/adapter.go index cd1f3affea5c6..a3ded051a3068 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. From 40ba62c43ec68f0a32567da4b9be95c8eb68e9c6 Mon Sep 17 00:00:00 2001 From: tiancaiamao Date: Thu, 31 Oct 2024 10:08:01 +0800 Subject: [PATCH 2/2] address comment --- pkg/executor/adapter.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/executor/adapter.go b/pkg/executor/adapter.go index a3ded051a3068..431efd09da0c6 100644 --- a/pkg/executor/adapter.go +++ b/pkg/executor/adapter.go @@ -615,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() {