ahuang98 commented on code in PR #18240: URL: https://github.com/apache/kafka/pull/18240#discussion_r1899071006
########## raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java: ########## @@ -926,29 +978,18 @@ private boolean handleVoteResponse( if (quorum.isLeader()) { logger.debug("Ignoring vote response {} since we already became leader for epoch {}", partitionResponse, quorum.epoch()); - } else if (quorum.isCandidate()) { - CandidateState state = quorum.candidateStateOrThrow(); + } else if (quorum.isNomineeState()) { + NomineeState state = quorum.nomineeStateOrThrow(); if (partitionResponse.voteGranted()) { state.recordGrantedVote(remoteNodeId); - maybeTransitionToLeader(state, currentTimeMs); + maybeTransitionForward(state, currentTimeMs); } else { state.recordRejectedVote(remoteNodeId); - - // If our vote is rejected, we go immediately to the random backoff. This - // ensures that we are not stuck waiting for the election timeout when the - // vote has become gridlocked. - if (state.isVoteRejected() && !state.isBackingOff()) { - logger.info("Insufficient remaining votes to become leader (rejected by {}). " + - "We will backoff before retrying election again", state.rejectingVoters()); - - state.startBackingOff( - currentTimeMs, - binaryExponentialElectionBackoffMs(state.retries()) - ); - } + maybeCandidateStartBackingOff(currentTimeMs); Review Comment: currently, pollProspective handles that logic - it checks if the vote has been rejected and if so transitions to unattached or follower. it should be okay to move that logic into the vote response handling (just adds to the method's complexity) -- 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