Skip to content

Commit

Permalink
raft: document why reuse candidate's term for vote response in stepCa…
Browse files Browse the repository at this point in the history
…ndidate

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

Signed-off-by: Gyuho Lee <[email protected]>
  • Loading branch information
gyuho committed Feb 22, 2018
1 parent 38846c2 commit 01db389
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions raft/raft.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 01db389

Please sign in to comment.