According to raft specification: Section 5.2: Leader election: A server remains in follower state as long as it receives valid RPCs from a leader or candidate. It is pretty clear that if the request is an append entry RPC, the follower should extend its timeout. But what if it is a requestVote RPC that is received by the follower? Should it reset its timeout? If the request vote RPC's term is greater than follower's term, should the follower increase its term as well?
Asked
Active
Viewed 487 times
1 Answers
1
If a follower receives a RequestVoteRpc
with a term that is higher than it's current term (and assuming that candidate’s log is at least as up-to-date as receiver’s log) the follower will:
- grant the vote to the candidate
- update it's term to the one received from the candidate
- remain in the
FOLLOWER
state - kick-off a new timer for
AppendEntriesRpc
The follower should increase its term because if the timer waiting for AppendEntriesRpc
expires, the follower will start a new election with a term greater than the term form the election he participated last.

msantl
- 371
- 2
- 6
-
Really appreciate the answer! There is still one more point to clarify, what if a follower/candidate receive a RequestRoteRequest whose term = its own term? should it reset its election timeout? I think there might be two case: the follower/candidate already voted for some node (for candidate, it is the current node self), or the follower has not yet voted for anyone – James Zhan Sep 26 '19 at 12:16
-
If a follower/candidate receives a ReqeustVoteRPC with term id being equal to it's own term id, it will respond with a vote denied response because this node either already voted for some other node or he voted for himself. It cannot be in a state where it didn't yet vote for someone and receiving a term id that the node is currently in. – msantl Sep 30 '19 at 10:00
-
Thanks again for the answer! The discussion really makes me think and understand the protocol better. What you say is true: For term N, if the node is follower, it must have known the leader, otherwise it is promoted from term N+1 as a candidate by voting itself. – James Zhan Oct 02 '19 at 09:58