Skip to content

Commit

Permalink
raft: ComputeLeadSupportUntil on every leader tick
Browse files Browse the repository at this point in the history
This commit calls ComputeLeadSupportUntil on every leader tick rather
than on every leader step. If the range is idle, the leader won't have
anything to step on, but it will keep ticking.

References: #139072

Release Note: None
  • Loading branch information
iskettaneh committed Jan 15, 2025
1 parent fd919f9 commit 1fb19e7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/raft/raft.go
Original file line number Diff line number Diff line change
Expand Up @@ -1210,6 +1210,9 @@ func (r *raft) tickElection() {
func (r *raft) tickHeartbeat() {
assertTrue(r.state == pb.StateLeader, "tickHeartbeat called by non-leader")

// Compute the LeadSupportUntil on every tick.
r.fortificationTracker.ComputeLeadSupportUntil(r.state)

// Check if we intended to step down. If so, step down if it's safe to do so.
// Otherwise, continue doing leader things.
if r.fortificationTracker.SteppingDown() && r.fortificationTracker.CanDefortify() {
Expand Down Expand Up @@ -1841,9 +1844,6 @@ func (r *raft) logMsgHigherTerm(m pb.Message, suffix redact.SafeString) {
type stepFunc func(r *raft, m pb.Message) error

func stepLeader(r *raft, m pb.Message) error {
// Compute the LeadSupportUntil on every tick.
r.fortificationTracker.ComputeLeadSupportUntil(r.state)

// These message types do not require any progress for m.From.
switch m.Type {
case pb.MsgBeat:
Expand Down

0 comments on commit 1fb19e7

Please sign in to comment.