-
Notifications
You must be signed in to change notification settings - Fork 9.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
raft: reset votes when becomePreCandidate #8346
raft: reset votes when becomePreCandidate #8346
Conversation
need test |
add a new test case, TestPreVoteWithSplitVote |
@@ -611,6 +611,7 @@ func (r *raft) becomePreCandidate() { | |||
// but doesn't change anything else. In particular it does not increase | |||
// r.Term or change r.Vote. | |||
r.step = stepCandidate | |||
r.votes = make(map[uint64]bool) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check line612? it says vote should not be changed for some reason. i do not feel it is safe to change the vote decision for one term either.
/cc @bdarnell
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably if pre-candidate times out, it needs to increase term to handle the potential vote spilt.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vote is what we voted for, it's in hard state. while votes is what other nodes grant/reject us, it's a memory state.
we can't change vote, but can change votes when a pre-vote happen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. I misread.
Lgtm |
raft: reset votes when becomePreCandidate. because the poll method wouldn't update grant state when key exists.
here is a case: