diff --git a/pkg/kv/kvserver/replica_consistency_test.go b/pkg/kv/kvserver/replica_consistency_test.go index 2660254ac5dc..0a3f545f824f 100644 --- a/pkg/kv/kvserver/replica_consistency_test.go +++ b/pkg/kv/kvserver/replica_consistency_test.go @@ -98,6 +98,10 @@ func TestStoreCheckpointSpans(t *testing.T) { addReplica := func(rangeID roachpb.RangeID, start, end string) { desc := makeDesc(rangeID, start, end) r := &Replica{RangeID: rangeID, startKey: desc.StartKey} + // NB: locking is unnecessary during Replica creation, but this is to work + // around the mutex hold asserts in "Locked" methods below. + r.mu.Lock() + defer r.mu.Unlock() r.mu.state.Desc = &desc r.isInitialized.Set(desc.IsInitialized()) require.NoError(t, s.addToReplicasByRangeIDLocked(r)) diff --git a/pkg/kv/kvserver/store.go b/pkg/kv/kvserver/store.go index 7fc016532ff8..c3761485d6b9 100644 --- a/pkg/kv/kvserver/store.go +++ b/pkg/kv/kvserver/store.go @@ -1893,7 +1893,7 @@ func (s *Store) Start(ctx context.Context, stopper *stop.Stopper) error { err = s.addToReplicasByRangeIDLocked(rep) if err == nil { // NB: no locking of the Replica is needed since it's being created, but - // just in case. + // it is asserted on in "Locked" methods. rep.mu.RLock() err = s.addToReplicasByKeyLockedReplicaRLocked(rep) rep.mu.RUnlock()