Skip to content

Commit

Permalink
[FIXED] RAFT node responds to VoteRequest with outdated Term
Browse files Browse the repository at this point in the history
A node's Term may be increased during handling of a VoteRequest.
When that was the case, the node was responding with a stale Term.
  • Loading branch information
mprimi committed Jan 31, 2024
1 parent a80fb4d commit 80e070d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions server/raft.go
Original file line number Diff line number Diff line change
Expand Up @@ -3934,6 +3934,10 @@ func (n *raft) processVoteRequest(vr *voteRequest) error {
n.resetElect(randCampaignTimeout())
}
}

// Term might have changed, make sure response has the most current
vresp.term = n.term

n.Unlock()

n.sendReply(vr.reply, vresp.encode())
Expand Down

0 comments on commit 80e070d

Please sign in to comment.