Skip to content

Commit e3c0767

Browse files
committed
kvserver: avoid leaked replica mutex during delegated snapshot
This one was possible hit. Interestingly, it would be "accidentally" fixed by cockroachdb#104657 as well, since after that PR we would never see a nil `status` here. Touches cockroachdb#106568
1 parent 3b35d3b commit e3c0767

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pkg/kv/kvserver/replica_command.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2953,15 +2953,15 @@ func (r *Replica) validateSnapshotDelegationRequest(
29532953
// that is also needs a snapshot, then any snapshot it sends will be useless.
29542954
r.mu.RLock()
29552955
replIdx := r.mu.state.RaftAppliedIndex + 1
2956-
29572956
status := r.raftStatusRLocked()
2957+
r.mu.RUnlock()
2958+
29582959
if status == nil {
29592960
// This code path is sometimes hit during scatter for replicas that
29602961
// haven't woken up yet.
29612962
return errors.Errorf("raft status not initialized")
29622963
}
29632964
replTerm := kvpb.RaftTerm(status.Term)
2964-
r.mu.RUnlock()
29652965

29662966
// Delegate has a lower term than the coordinator. This typically means the
29672967
// lease has been transferred, and we should not process this request. There

0 commit comments

Comments
 (0)