Skip to content

Commit

Permalink
kvserver: squash data race
Browse files Browse the repository at this point in the history
Fixes #74932; we were reading from the replicas map without having
acquired the prerequisite lock.

Release note: None
  • Loading branch information
irfansharif committed Jan 18, 2022
1 parent 6c30e38 commit 3218353
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/kv/kvserver/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3218353

Please sign in to comment.