Skip to content
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

NRG: Campaign early unless already candidate #6511

Merged
merged 1 commit into from
Feb 15, 2025

Conversation

MauriceVanVeen
Copy link
Member

If an outdated server wants to become leader, other servers can recognize they have a more up-to-date and start campaigning early to speed up the leader election process.

However, if two servers would both become candidate at the same time due to this, and one of the candidate's log is slightly more ahead it would again start campaigning early. This can essentially short-circuit the voting process, starting a new leader election/term while that wouldn't be necessary to do. That ahead candidate could just reject the vote for the other candidate, and wait for successful votes for itself to come in.

Signed-off-by: Maurice van Veen [email protected]

@MauriceVanVeen MauriceVanVeen requested a review from a team as a code owner February 14, 2025 13:32
@@ -4138,11 +4138,10 @@ func (n *raft) processVoteRequest(vr *voteRequest) error {
n.vote = vr.candidate
n.writeTermVote()
n.resetElectionTimeout()
} else {
if vr.term >= n.term && n.vote == noVote {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have removed the vr.term >= n.term part of the condition as well as the n.term = vr.term as they don't do anything at the moment.

If vr.term < n.term we already deny requests, and if vr.term > n.term we update above. So when we come here vr.term == n.term already.

Copy link
Member

@neilalexander neilalexander left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM after discussing with Maurice.

@derekcollison derekcollison merged commit 69ff59e into main Feb 15, 2025
5 checks passed
@derekcollison derekcollison deleted the maurice/nrg-campaign-early branch February 15, 2025 01:47
neilalexander added a commit that referenced this pull request Feb 18, 2025
Includes the following:

- #6507
- #6497
- #6476
- #6511
- #6513
- #6517
- #6515
- #6519
- #6521

Signed-off-by: Neil Twigg <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants