Skip to content

Commit

Permalink
Merge pull request #133847 from cockroachdb/blathers/backport-release…
Browse files Browse the repository at this point in the history
…-24.3-133461

release-24.3: rac2: fix TestRangeController testingRCRange.mu lock ordering
  • Loading branch information
kvoli authored Oct 30, 2024
2 parents 6cc3b2e + c6f3b8e commit 14e8f7a
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions pkg/kv/kvserver/kvflowcontrol/rac2/range_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ func (s *testingRCState) init(t *testing.T, ctx context.Context) {
func sortReplicas(r *testingRCRange) []roachpb.ReplicaDescriptor {
r.mu.Lock()
defer r.mu.Unlock()
return sortReplicasLocked(r)
}

func sortReplicasLocked(r *testingRCRange) []roachpb.ReplicaDescriptor {
return sortReplicaSet(r.mu.r.replicaSet)
}

Expand Down Expand Up @@ -504,7 +508,9 @@ func (r *testingRCRange) startWaitForEval(name string, pri admissionpb.WorkPrior
func (r *testingRCRange) admit(ctx context.Context, storeID roachpb.StoreID, av AdmittedVector) {
r.mu.Lock()
defer r.mu.Unlock()
for _, replica := range r.mu.r.replicaSet {

for _, replDesc := range sortReplicasLocked(r) {
replica := r.mu.r.replicaSet[replDesc.ReplicaID]
if replica.desc.StoreID == storeID {
for _, v := range av.Admitted {
// Ensure that Match doesn't lag behind the highest index in the
Expand Down Expand Up @@ -918,11 +924,14 @@ func (t *testingProbeToCloseTimerScheduler) ScheduleSendStreamCloseRaftMuLocked(
}
timer.MarkRead()
func() {
rc := t.state.ranges[rangeID].rc
rc.opts.ReplicaMutexAsserter.RaftMu.Lock()
defer rc.opts.ReplicaMutexAsserter.RaftMu.Unlock()
r := t.state.ranges[rangeID]
event := r.makeRaftEventWithReplicasState()

r.rc.opts.ReplicaMutexAsserter.RaftMu.Lock()
defer r.rc.opts.ReplicaMutexAsserter.RaftMu.Unlock()

require.NoError(t.state.t,
rc.HandleRaftEventRaftMuLocked(ctx, t.state.ranges[rangeID].makeRaftEventWithReplicasState()))
r.rc.HandleRaftEventRaftMuLocked(ctx, event))
}()
}()
}
Expand Down

0 comments on commit 14e8f7a

Please sign in to comment.