Skip to content

Commit

Permalink
raft: remove unneeded MaybeUpdate call
Browse files Browse the repository at this point in the history
The Progress.MaybeUpdate is only needed on the leader. In the
raft.restore() method, the state is either Follower or Candidate.
Non-leader states don't have a replication flow, and don't need to track
Match/Next index.

Signed-off-by: Pavel Kalinnikov <[email protected]>
  • Loading branch information
pav-kv committed Feb 15, 2024
1 parent 53007f4 commit 79a64f4
Showing 1 changed file with 0 additions and 3 deletions.
3 changes: 0 additions & 3 deletions raft.go
Original file line number Diff line number Diff line change
Expand Up @@ -1902,9 +1902,6 @@ func (r *raft) restore(s pb.Snapshot) bool {

assertConfStatesEquivalent(r.logger, cs, r.switchToConfig(cfg, trk))

pr := r.trk.Progress[r.id]
pr.MaybeUpdate(pr.Next - 1) // TODO(tbg): this is untested and likely unneeded

last := r.raftLog.lastEntryID()
r.logger.Infof("%x [commit: %d, lastindex: %d, lastterm: %d] restored snapshot [index: %d, term: %d]",
r.id, r.raftLog.committed, last.index, last.term, id.index, id.term)
Expand Down

0 comments on commit 79a64f4

Please sign in to comment.