Skip to content

Commit

Permalink
Remove unnecessary term handling
Browse files Browse the repository at this point in the history
No need to set term if granting vote since receiving a request with a higher or lower term is handled earlier in this method.

Signed-off-by: reubenninan <reuben@nats.io>
  • Loading branch information
ReubenMathew committed Oct 2, 2024
1 parent f1d39fa commit 4b77836
Showing 1 changed file with 0 additions and 6 deletions.
6 changes: 0 additions & 6 deletions server/raft.go
Original file line number Diff line number Diff line change
Expand Up @@ -4082,15 +4082,9 @@ func (n *raft) processVoteRequest(vr *voteRequest) error {
voteOk := n.vote == noVote || n.vote == vr.candidate
if voteOk && (vr.lastTerm > n.pterm || vr.lastTerm == n.pterm && vr.lastIndex >= n.pindex) {
vresp.granted = true
n.term = vr.term
n.vote = vr.candidate
n.writeTermVote()
n.resetElectionTimeout()
} else {
if vr.term >= n.term && n.vote == noVote {
n.term = vr.term
n.resetElect(randCampaignTimeout())
}
}

// Term might have changed, make sure response has the most current
Expand Down

0 comments on commit 4b77836

Please sign in to comment.