fix: reject non-voter leadership transfer targets#3
Draft
anyasabo wants to merge 1 commit into
Draft
Conversation
LeadershipTransferToServer can currently target a demoted server and trigger unnecessary election churn. Reject non-voter targets up front and add a regression test to confirm leader/term stability after failed transfer attempts. Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
LeadershipTransferToServercan accept an explicit target that has already been demoted to non-voter.The generic transfer path (
LeadershipTransfer) already avoids non-voters by selection, but the explicit-target path did not enforce suffrage, so stale automation/operator requests could still attempt transfer to ineligible targets.How this can happen in concrete terms
Land followerF.Fis demoted (or removed then re-added as non-voter) during membership churn.Fas preferred transfer target (stale cache/config).LeadershipTransferToServer(F)is issued.Flacking a vote.Mitigations that help (but are not complete)
LeadershipTransfer()(auto-pick) over explicit target when possible.Gap addressed by this PR: explicit target path now enforces voter suffrage directly.
Impact
Availability/control-plane stability risk:
How we would notice in production
Provenance / Preconditions
eba83432, 2019), with later flow updates (d68b78bc, 2022).LeadershipTransferToServer, andWhat this PR changes
Reviewer reproduction (live in-process cluster)
Reproduce problematic behavior pre-fix
git checkout 6b313b5^git checkout fix/leadership-transfer-nonvoter-target -- raft_test.gogo test -run "TestRaft_LeadershipTransferToNonvoterDoesNotDisruptLeader" -count=20 .Verify fixed behavior
fix/leadership-transfer-nonvoter-target).go test -run "TestRaft_LeadershipTransfer(IgnoresNonvoters|ToNonvoterDoesNotDisruptLeader)$" -count=1 .Test plan
go test -run "TestRaft_LeadershipTransfer(IgnoresNonvoters|ToNonvoterDoesNotDisruptLeader)$" -count=1 .