Skip to content

Commit

Permalink
sql: don't overwrite ctx with nil on failure
Browse files Browse the repository at this point in the history
SetupLocalSyncFlow would return a nil ctx with an error in setupFlows if an
error occurred. The previous version would overwrite a ctx in the outer scope
just to return it. This commit no longer overwrites ctx and simply returns the
new ctx. On master, this nil ctx would not have any consequences although this
commit is good hygiene, but 20.2 uses this ctx in a defer, which would cause a
panic.

Release note (bug fix): Fix a nil pointer panic edge case in query setup code.
  • Loading branch information
asubiotto committed Jan 15, 2021
1 parent a786c51 commit 2096345
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions pkg/sql/distsql_running.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,12 +224,7 @@ func (dsp *DistSQLPlanner) setupFlows(
localReq := setupReq
localReq.Flow = *flows[thisNodeID]
defer physicalplan.ReleaseSetupFlowRequest(&localReq)
ctx, flow, err := dsp.distSQLSrv.SetupLocalSyncFlow(ctx, evalCtx.Mon, &localReq, recv, localState)
if err != nil {
return nil, nil, err
}

return ctx, flow, nil
return dsp.distSQLSrv.SetupLocalSyncFlow(ctx, evalCtx.Mon, &localReq, recv, localState)
}

// Run executes a physical plan. The plan should have been finalized using
Expand Down

0 comments on commit 2096345

Please sign in to comment.