From fba8539cdc63fb3a49b1a8a2e0058ad81d169150 Mon Sep 17 00:00:00 2001 From: Michael Erickson Date: Thu, 30 Mar 2023 19:52:00 +0000 Subject: [PATCH] physicalplan: debugging for segfault in fakeSpanResolverIterator.Seek Break up a line that is segfaulting into several lines, so that we can tell which part is to blame if it happens again. Informs: #100051 Informs: #100108 Epic: None Release note: None --- pkg/sql/physicalplan/fake_span_resolver.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/sql/physicalplan/fake_span_resolver.go b/pkg/sql/physicalplan/fake_span_resolver.go index 08b1cbb36a3d..dca93c2592e2 100644 --- a/pkg/sql/physicalplan/fake_span_resolver.go +++ b/pkg/sql/physicalplan/fake_span_resolver.go @@ -167,11 +167,15 @@ func (fit *fakeSpanResolverIterator) Seek( // Build ranges corresponding to the fake splits and assign them random // replicas. fit.ranges = make([]fakeRange, len(splits)-1) + // TODO(michae2): Condense this logic when #100051 is fixed. + nodes := fit.fsr.nodes + n := len(nodes) for i := range fit.ranges { + j := fit.rng.Intn(n) fit.ranges[i] = fakeRange{ startKey: splits[i], endKey: splits[i+1], - replica: fit.fsr.nodes[fit.rng.Intn(len(fit.fsr.nodes))], + replica: nodes[j], } }