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 -- 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: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org