Skip to content

Commit

Permalink
sql: fix recent leak of a goroutine
Browse files Browse the repository at this point in the history
Release note: None
  • Loading branch information
yuzefovich committed Jul 21, 2022
1 parent 457d724 commit 4d4afbc
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/sql/conn_executor_exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,10 @@ func (ex *connExecutor) execStmtInOpenState(

var cancelQuery context.CancelFunc
ctx, cancelQuery = contextutil.WithCancel(ctx)
// When we exit this method, the execution flow must have finished, so
// canceling the context here is safe. This cancellation is needed to
// prevent a leak of a goroutine.
defer cancelQuery()

makeErrEvent := func(err error) (fsm.Event, fsm.EventPayload, error) {
ev, payload := ex.makeErrEvent(err, ast)
Expand Down

0 comments on commit 4d4afbc

Please sign in to comment.