Skip to content

Commit

Permalink
kvserver: avoid leaked replica mutex during delegated snapshot
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tbg committed Jul 12, 2023
1 parent 3b35d3b commit e3c0767
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/kv/kvserver/replica_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -2953,15 +2953,15 @@ func (r *Replica) validateSnapshotDelegationRequest(
// that is also needs a snapshot, then any snapshot it sends will be useless.
r.mu.RLock()
replIdx := r.mu.state.RaftAppliedIndex + 1

status := r.raftStatusRLocked()
r.mu.RUnlock()

if status == nil {
// This code path is sometimes hit during scatter for replicas that
// haven't woken up yet.
return errors.Errorf("raft status not initialized")
}
replTerm := kvpb.RaftTerm(status.Term)
r.mu.RUnlock()

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

0 comments on commit e3c0767

Please sign in to comment.