From 626b72d165d09ee85874d710465b1b1f2b7e14fa Mon Sep 17 00:00:00 2001 From: Solon Gordon Date: Mon, 25 Jun 2018 13:00:50 -0400 Subject: [PATCH] distsql: do not plan against unhealthy nodes A bug was introduced in 0cd1da0 which allows table readers to be planned on unhealthy or incompatible nodes for LIMIT queries. They should use the gateway node instead. This was causing a panic in execution because the node was not in the nodeAddresses map. Fixes #26140 Release note (bug fix): Fixed 'node not in nodeAddresses map' panic, which could occur when distributed LIMIT queries were run on a cluster with at least one unhealthy node. --- pkg/sql/distsql_physical_planner.go | 1 + pkg/sql/distsqlplan/physical_plan.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/sql/distsql_physical_planner.go b/pkg/sql/distsql_physical_planner.go index 583113dde2c4..edd2b1d3a5d2 100644 --- a/pkg/sql/distsql_physical_planner.go +++ b/pkg/sql/distsql_physical_planner.go @@ -932,6 +932,7 @@ func (dsp *DistSQLPlanner) getNodeIDForScan( nodeID := replInfo.NodeDesc.NodeID if err := dsp.checkNodeHealthAndVersion(planCtx, replInfo.NodeDesc); err != nil { log.Eventf(planCtx.ctx, "not planning on node %d. %v", nodeID, err) + return dsp.nodeDesc.NodeID, nil } return nodeID, nil } diff --git a/pkg/sql/distsqlplan/physical_plan.go b/pkg/sql/distsqlplan/physical_plan.go index bf36130fbd61..843bce8c6af1 100644 --- a/pkg/sql/distsqlplan/physical_plan.go +++ b/pkg/sql/distsqlplan/physical_plan.go @@ -719,7 +719,7 @@ func (p *PhysicalPlan) PopulateEndpoints(nodeAddresses map[roachpb.NodeID]string var ok bool endpoint.TargetAddr, ok = nodeAddresses[p2.Node] if !ok { - panic(fmt.Sprintf("node %d node in nodeAddresses map", p2.Node)) + panic(fmt.Sprintf("node %d not in nodeAddresses map", p2.Node)) } }