ahuang98 commented on code in PR #18240:
URL: https://github.com/apache/kafka/pull/18240#discussion_r1897014715
##########
raft/src/main/java/org/apache/kafka/raft/UnattachedState.java:
##########
@@ -71,13 +73,7 @@ public UnattachedState(
@Override
public ElectionState election() {
- if (votedKey.isPresent()) {
- return ElectionState.withVotedCandidate(epoch, votedKey().get(),
voters);
- } else if (leaderId.isPresent()) {
- return ElectionState.withElectedLeader(epoch, leaderId.getAsInt(),
voters);
- } else {
- return ElectionState.withUnknownLeader(epoch, voters);
- }
+ return new ElectionState(epoch, leaderId, votedKey, voters);
Review Comment:
Retaining both leaderId and votedKey also can help other replicas find the
leader faster (though not needed for correctness) -
UnattachedVoted w/ leader will reject vote requests w/ a leaderId
UnattachedVoted w/o leader will reject vote request w/o a leaderId
If we only persist one, then on startup a replica just doesn't have all the
information it _could_ have
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]