Skip to content

Commit

Permalink
fix: issue 610
Browse files Browse the repository at this point in the history
  • Loading branch information
576470954 committed Sep 20, 2023
1 parent 0389c17 commit 24fc4a0
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions pkg/datasource/sql/exec/at/select_for_update_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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,
Expand Down

0 comments on commit 24fc4a0

Please sign in to comment.