From 24fc4a077be338eab1b854197daed94b0dfa09e5 Mon Sep 17 00:00:00 2001 From: zhangz <576470954@qq.com> Date: Wed, 20 Sep 2023 18:09:05 +0800 Subject: [PATCH] fix: issue 610 --- .../sql/exec/at/select_for_update_executor.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/datasource/sql/exec/at/select_for_update_executor.go b/pkg/datasource/sql/exec/at/select_for_update_executor.go index 3e51a97b1..289b666b6 100644 --- a/pkg/datasource/sql/exec/at/select_for_update_executor.go +++ b/pkg/datasource/sql/exec/at/select_for_update_executor.go @@ -174,12 +174,6 @@ func (s *selectForUpdateExecutor) doExecContext(ctx context.Context, f exec.Call return nil, fmt.Errorf("not support savepoint. please check your db version") } - // execute business SQL, try to get local lock - result, err = f(ctx, s.execContext.Query, s.execContext.NamedValues) - if err != nil { - return nil, err - } - // query primary key values var lockKey string _, err = s.exec(ctx, s.selectPKSQL, s.execContext.NamedValues, func(rows driver.Rows) { @@ -194,6 +188,12 @@ func (s *selectForUpdateExecutor) doExecContext(ctx context.Context, f exec.Call return nil, nil } + // execute business SQL, try to get local lock + result, err = f(ctx, s.execContext.Query, s.execContext.NamedValues) + if err != nil { + return nil, err + } + // check global lock lockable, err := datasource.GetDataSourceManager(branch.BranchTypeAT).LockQuery(ctx, rm.LockQueryParam{ Xid: s.execContext.TxCtx.XID,