From 32183532321e37d7a03f135c83a9b26c28454f21 Mon Sep 17 00:00:00 2001 From: irfan sharif Date: Mon, 17 Jan 2022 23:16:51 -0500 Subject: [PATCH] kvserver: squash data race Fixes #74932; we were reading from the replicas map without having acquired the prerequisite lock. Release note: None --- pkg/kv/kvserver/store.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/kv/kvserver/store.go b/pkg/kv/kvserver/store.go index 893094aaa550..190ea155c6f4 100644 --- a/pkg/kv/kvserver/store.go +++ b/pkg/kv/kvserver/store.go @@ -2336,6 +2336,9 @@ func (s *Store) onSpanConfigUpdate(ctx context.Context, updated roachpb.Span) { } now := s.cfg.Clock.NowAsClockTimestamp() + + s.mu.RLock() + defer s.mu.RUnlock() if err := s.mu.replicasByKey.VisitKeyRange(ctx, sp.Key, sp.EndKey, AscendingKeyOrder, func(ctx context.Context, it replicaOrPlaceholder) error { repl := it.repl