soarez commented on code in PR #12716:
URL: https://github.com/apache/kafka/pull/12716#discussion_r996349324
##########
raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java:
##########
@@ -647,12 +647,13 @@ private boolean handleVoteResponse(
}
}
- private int binaryExponentialElectionBackoffMs(int retries) {
+ // visible for testing
+ int binaryExponentialElectionBackoffMs(int retries) {
if (retries <= 0) {
throw new IllegalArgumentException("Retries " + retries + " should
be larger than zero");
}
// upper limit exponential co-efficients at 20 to avoid overflow
- return Math.min(RETRY_BACKOFF_BASE_MS * random.nextInt(2 <<
Math.min(20, retries - 1)),
+ return Math.min(RETRY_BACKOFF_BASE_MS * random.nextInt(2 <<
Math.min(20, retries)),
Review Comment:
Given my understanding of your intention from the PR description:
> That means, when multiple candidates tried to backoff for the 1st retries,
they will all get 0ms backoff, and then keep conflicting again.
Is this change enough?
For the 1st retry — considering the call
`binaryExponentialElectionBackoffMs(1)` — this changes `randomNextInt(2)` to
`randomNextInt(4)` which goes from 50% chance to 25% chance of getting a 0.
--
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]