ahuang98 commented on code in PR #18240:
URL: https://github.com/apache/kafka/pull/18240#discussion_r1901235462
##########
raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java:
##########
@@ -667,7 +668,8 @@ private boolean maybeTransitionToLeader(CandidateState
state, long currentTimeMs
}
private boolean maybeTransitionToCandidate(ProspectiveState state, long
currentTimeMs) {
- if (state.epochElection().isVoteGranted()) {
+ // If replica is the only voter, it should transition to candidate
immediately
+ if (state.epochElection().isVoteGranted() || quorum.isOnlyVoter()) {
Review Comment:
Added four tests for this, starting at
`testInitializeAsOnlyVoterWithEmptyElectionState`
> confirm that we have a test for this in ProspectiveStateTest and
CandidateStateTest
Confirmed!
##########
raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java:
##########
@@ -667,7 +668,8 @@ private boolean maybeTransitionToLeader(CandidateState
state, long currentTimeMs
}
private boolean maybeTransitionToCandidate(ProspectiveState state, long
currentTimeMs) {
- if (state.epochElection().isVoteGranted()) {
+ // If replica is the only voter, it should transition to candidate
immediately
+ if (state.epochElection().isVoteGranted() || quorum.isOnlyVoter()) {
Review Comment:
Added four tests for this, starting at
`testInitializeAsOnlyVoterWithEmptyElectionState`
> confirm that we have a test for this in ProspectiveStateTest and
CandidateStateTest
Confirmed!
--
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]