Skip to content

KAFKA-18389: Preserve votedKey when transitioning to leader state#22203

Open
lh0156 wants to merge 1 commit intoapache:trunkfrom
lh0156:KAFKA-18389-preserve-votedkey
Open

KAFKA-18389: Preserve votedKey when transitioning to leader state#22203
lh0156 wants to merge 1 commit intoapache:trunkfrom
lh0156:KAFKA-18389-preserve-votedkey

Conversation

@lh0156
Copy link
Copy Markdown

@lh0156 lh0156 commented May 4, 2026

Summary

This patch preserves the candidate votedKey when transitioning to LeaderState.

Before this change, LeaderState.election() always returned an elected-leader ElectionState with an empty votedKey. Since QuorumState.transitionToLeader writes the new state's election state to the quorum state store, the candidate's self-vote could be dropped during the candidate-to-leader transition.

The patch passes the candidate election state's votedKey into LeaderState and keeps the same value across the soft ResignedState representation. This keeps the in-memory and persisted election-state representation consistent after a candidate becomes leader and later resigns.

Testing

./gradlew :raft:unitTest

@github-actions github-actions Bot added triage PRs from the community kraft labels May 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kraft triage PRs from the community

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant