raft: document why reuse candidate's term for vote response in stepCandidate

"stepCandidate" should reuse candidate's own term, not term in Message,
because pre-vote is requested with future term.

Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
This commit is contained in:
Gyuho Lee
2018-02-21 16:00:43 -08:00
parent 38846c220a
commit 01db389ea8

View File

@@ -1148,6 +1148,8 @@ func stepCandidate(r *raft, m pb.Message) error {
r.bcastAppend()
}
case len(r.votes) - gr:
// pb.MsgPreVoteResp contains future term of pre-candidate
// m.Term > r.Term; reuse r.Term
r.becomeFollower(r.Term, None)
}
case pb.MsgTimeoutNow: