Skip to content

Commit

Permalink
kvserver: move maybeRefreshProposals to own method
Browse files Browse the repository at this point in the history
Allows the use of deferred unlock.

Release note: None

Part of: cockroachdb#105366
  • Loading branch information
andrewbaptist committed May 14, 2024
1 parent a236d9b commit ecdf544
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions pkg/kv/kvserver/replica_raft.go
Original file line number Diff line number Diff line change
Expand Up @@ -1141,11 +1141,7 @@ func (r *Replica) handleRaftReadyRaftMuLocked(
if r.store.TestingKnobs().EnableUnconditionalRefreshesInRaftReady {
refreshReason = reasonNewLeaderOrConfigChange
}
if refreshReason != noReason {
r.mu.Lock()
r.refreshProposalsLocked(ctx, 0 /* refreshAtDelta */, refreshReason)
r.mu.Unlock()
}
r.maybeRefreshProposals(ctx, refreshReason)

// NB: if we just processed a command which removed this replica from the
// raft group we will early return before this point. This, combined with
Expand Down Expand Up @@ -1199,6 +1195,14 @@ func (r *Replica) handleRaftReadyRaftMuLocked(
return stats, nil
}

func (r *Replica) maybeRefreshProposals(ctx context.Context, refreshReason refreshRaftReason) {
if refreshReason != noReason {
r.mu.Lock()
defer r.mu.Unlock()
r.refreshProposalsLocked(ctx, 0 /* refreshAtDelta */, refreshReason)
}
}

// asyncReady encapsulates the messages that are ready to be sent to other peers
// or to be sent to local storage routines when async storage writes are enabled.
// All fields in asyncReady are read-only.
Expand Down

0 comments on commit ecdf544

Please sign in to comment.