RAFT: Follower's term is not incremented for request_vote RPC
jaseemabid opened this issue · 4 comments
jaseemabid commented
Follower's term is only incremented after it receives a heartbeat.
Here is the relevant section from the spec.
\* Server i receives a RequestVote request from server j with
\* m.mterm <= currentTerm[i].
HandleRequestVoteRequest(i, j, m) ==
LET logOk == \/ m.mlastLogTerm > LastTerm(log[i])
\/ /\ m.mlastLogTerm = LastTerm(log[i])
/\ m.mlastLogIndex >= Len(log[i])
grant == /\ m.mterm = currentTerm[i]
/\ logOk
/\ votedFor[i] \in {Nil, j}
IN /\ m.mterm <= currentTerm[i]
/\ \/ grant /\ votedFor' = [votedFor EXCEPT ![i] = j]
\/ ~grant /\ UNCHANGED votedFor
/\ Reply([mtype |-> RequestVoteResponse,
mterm |-> currentTerm[i],
mvoteGranted |-> grant,
\* mlog is used just for the `elections' history variable for
\* the proof. It would not exist in a real implementation.
mlog |-> log[i],
msource |-> i,
mdest |-> j],
m)
/\ UNCHANGED <<state, currentTerm, candidateVars, leaderVars, logVars>>
The reply contains original term of the follower.
jaseemabid commented
This might be the fix. https://github.com/jaseemabid/thesecretlivesofdata/commit/a9275771ce2e4840a50efd1ada189c3fd87245d5
Any comments?
jaseemabid commented
@ongardie 's comment here #1 (comment) suggest otherwise.
Can you please verify?
jaseemabid commented
This is slightly confusing, so I asked in the mailing list for clarification. https://groups.google.com/forum/#!topic/raft-dev/Dn6eNSCAjeQ
jaseemabid commented
My bad, the behavior is correct. @swvist clarified in the mailing list. Closing this bug.