From 2096345f1baf221d03d6018325b7cb9974ba48c2 Mon Sep 17 00:00:00 2001 From: Alfonso Subiotto Marques Date: Fri, 15 Jan 2021 10:15:17 +0100 Subject: [PATCH] sql: don't overwrite ctx with nil on failure 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. --- pkg/sql/distsql_running.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/pkg/sql/distsql_running.go b/pkg/sql/distsql_running.go index 278cd82fcdb0..67f640041bf5 100644 --- a/pkg/sql/distsql_running.go +++ b/pkg/sql/distsql_running.go @@ -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