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

kvserver: force-campaign leaseholder on leader removal #104969

Merged
merged 3 commits into from
Jun 16, 2023

Commits on Jun 16, 2023

  1. kvserver: clarify Raft campaign behavior with PreVote+CheckQuorum

    This patch tweaks and clarifies explicit campaign behavior when Raft
    PreVote and CheckQuorum are enabled. In this case, followers will only
    grant prevotes if they haven't heard from a leader in the past election
    timeout. It also adds a test covering this.
    
    Epic: none
    Release note: None
    erikgrinaker committed Jun 16, 2023
    Configuration menu
    Copy the full SHA
    4038ef8 View commit details
    Browse the repository at this point in the history
  2. kvserver: add Replica.forceCampaignLocked()

    This patch adds `forceCampaignLocked()`, which can be used to force an
    election, transitioning the replica directly to candidate and bypassing
    PreVote+CheckQuorum.
    
    Epic: none
    Release note: None
    erikgrinaker committed Jun 16, 2023
    Configuration menu
    Copy the full SHA
    99c8d4e View commit details
    Browse the repository at this point in the history
  3. kvserver: force-campaign leaseholder on leader removal

    Previously, when the leader was removed from the range via a conf
    change, the first voter in the range descriptor would campaign to avoid
    waiting for an election timeout. This had a few drawbacks:
    
    * If the first voter is unavailable or lags, noone will campaign.
    
    * If the first voter isn't the leaseholder, it has to immediately
      transfer leadership to the leaseholder.
    
    * It used Raft PreVote, so it wouldn't be able to win when CheckQuorum
      is enabled, since followers won't grant votes when they've recently
      heard from the leader.
    
    This patch instead campaigns on the current leaseholder. We know there
    can only be one, avoiding election ties. The conf change is typically
    proposed by the leaseholder anyway so it's likely to be up-to-date. And
    we want it to be colocated with the leader. If there is no leaseholder
    then waiting out the election timeout is less problematic, since either
    we'll have to wait out the lease interval anyway, or the range is idle.
    
    It also forces an election by transitioning directly to candidate,
    bypassing PreVote. This is ok, since we know the current leader is dead.
    
    To avoid election ties in mixed 23.1/23.2 clusters, we retain the old
    voter designation until the upgrade is finalized, but always force an
    election instead of using pre-vote.
    
    Epic: none
    Release note: None
    erikgrinaker committed Jun 16, 2023
    Configuration menu
    Copy the full SHA
    2959dda View commit details
    Browse the repository at this point in the history