jsancio commented on code in PR #18240:
URL: https://github.com/apache/kafka/pull/18240#discussion_r1901113187


##########
raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java:
##########
@@ -985,36 +982,54 @@ private boolean handleVoteResponse(
                     maybeTransitionForward(state, currentTimeMs);
                 } else {
                     state.recordRejectedVote(remoteNodeId);
-                    maybeCandidateStartBackingOff(currentTimeMs);
+                    maybeHandleElectionLoss(currentTimeMs);
                 }
             } else {
-                logger.debug("Ignoring vote response {} since we are no longer 
a VotingState " +
-                        "(Prospective or Candidate) in epoch {}",
-                    partitionResponse, quorum.epoch());
+                logger.debug(
+                    "Ignoring vote response {} since we are no longer a 
NomineeState " +
+                    "(Prospective or Candidate) in epoch {}",
+                    partitionResponse,
+                    quorum.epoch()
+                );
             }
             return true;
         } else {
             return handleUnexpectedError(error, responseMetadata);
         }
     }
 
-    private void maybeCandidateStartBackingOff(long currentTimeMs) {
-        // If in candidate state and vote is rejected, go immediately to a 
random, exponential backoff. The
-        // backoff starts low to prevent needing to wait the entire election 
timeout when the vote
-        // result has already been determined. The randomness prevents the 
next election from being
-        // gridlocked with another nominee due to timing. The exponential 
aspect limits epoch churn when
-        // the replica has failed multiple elections in succession.
+    /**
+     * On election loss, if replica is prospective it will transition to 
unattached or follower state.
+     * If replica is candidate, it will start backing off.
+     */
+    private void maybeHandleElectionLoss(long currentTimeMs) {

Review Comment:
   Yes. We discussed this offline.



-- 
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]

Reply via email to