-
Notifications
You must be signed in to change notification settings - Fork 96
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
Fix a bug where the leader is never elected even if the majority of the members are alive. #442
Conversation
@sile thank you for your ongoing contributions! We will get to this PR in the next couple of weeks. |
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.
Higher states are only really exited when encountering a higher term which this goes against. In this case I think it should be sufficient for the candidate to simply reply to the pre-vote request (with a success) as this would allow the pre-voter to potentially proceed to candidate state itself and eventually win the election.
@kjnilsson That sounds reasonable. Thank you for your comment! I have incorporated the change in commit e6bbd1a. Here are the current results of the repro function:
|
Thank you for reviewing and merging this PR! |
Proposed Changes
This PR addresses the issue reported in #439.
To summarize #439, if there is a candidate member and a pre_vote member where the pre_vote member has a higher log index than the candidate member, neither of them can ever be elected as the leader.
(This holds true even if there are additional
N / 2 - 1
or fewer followers without election timers, whereN
is the cluster size.)This PR adds a branch to
ra_server:handle_candidate(#pre_vote_rpc{}, ...)
to handle cases where the pre_vote member has a higher log index. By the new branch, when such a message is received, the candidate transitions to the follower state.I think this is somewhat ad-hoc. However, since I don't know much about the
ra
code base (especially regarding the role of thepre_vote
state), I made a patch to minimize the impact range.Feel free to suggest any better alternative approaches.
Closes #439.
FYI
By applying the patch for reproduction from issue #439 to this PR branch, the execution result became as follows:
Types of Changes
What types of changes does your code introduce to this project?
Put an
x
in the boxes that applyChecklist
Put an
x
in the boxes that apply. You can also fill these out after creatingthe PR. If you're unsure about any of them, don't hesitate to ask on the
mailing list. We're here to help! This is simply a reminder of what we are
going to look for before merging your code.
CONTRIBUTING.md
documentFurther Comments
If this is a relatively large or complex change, kick off the discussion by
explaining why you chose the solution you did and what alternatives you
considered, etc.