benbjohnson/thesecretlivesofdata

RAFT: Follower's term is not incremented for request_vote RPC

jaseemabid opened this issue · 4 comments

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.

@ongardie 's comment here #1 (comment) suggest otherwise.

Can you please verify?

This is slightly confusing, so I asked in the mailing list for clarification. https://groups.google.com/forum/#!topic/raft-dev/Dn6eNSCAjeQ

My bad, the behavior is correct. @swvist clarified in the mailing list. Closing this bug.