From 01db389ea8f8cd78ee84273b2f54feefe136a214 Mon Sep 17 00:00:00 2001 From: Gyuho Lee Date: Wed, 21 Feb 2018 16:00:43 -0800 Subject: [PATCH] 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 --- raft/raft.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/raft/raft.go b/raft/raft.go index 235a38b51f0..ef9b86597e5 100644 --- a/raft/raft.go +++ b/raft/raft.go @@ -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: