Browse Source

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>
Gyuho Lee 7 years ago
parent
commit
01db389ea8
1 changed files with 2 additions and 0 deletions
  1. 2 0
      raft/raft.go

+ 2 - 0
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: