You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2021/03/31 21:48:04 UTC

[GitHub] [kafka] cmccabe opened a new pull request #10455: MINOR: Support ExponentialBackoff without jitter

cmccabe opened a new pull request #10455:
URL: https://github.com/apache/kafka/pull/10455


   


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] cmccabe merged pull request #10455: MINOR: Support ExponentialBackoff without jitter

Posted by GitBox <gi...@apache.org>.
cmccabe merged pull request #10455:
URL: https://github.com/apache/kafka/pull/10455


   


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] mumrah commented on a change in pull request #10455: MINOR: Support ExponentialBackoff without jitter

Posted by GitBox <gi...@apache.org>.
mumrah commented on a change in pull request #10455:
URL: https://github.com/apache/kafka/pull/10455#discussion_r607882775



##########
File path: clients/src/main/java/org/apache/kafka/common/utils/ExponentialBackoff.java
##########
@@ -47,7 +47,8 @@ public long backoff(long attempts) {
         }
         double exp = Math.min(attempts, this.expMax);
         double term = initialInterval * Math.pow(multiplier, exp);
-        double randomFactor = ThreadLocalRandom.current().nextDouble(1 - jitter, 1 + jitter);
+        double randomFactor = jitter < Double.MIN_NORMAL ? 1.0 :

Review comment:
       Gotcha, I misunderstood the docs and thought it was ~1. Let's keep it as-is




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] cmccabe commented on a change in pull request #10455: MINOR: Support ExponentialBackoff without jitter

Posted by GitBox <gi...@apache.org>.
cmccabe commented on a change in pull request #10455:
URL: https://github.com/apache/kafka/pull/10455#discussion_r607330220



##########
File path: clients/src/main/java/org/apache/kafka/common/utils/ExponentialBackoff.java
##########
@@ -47,7 +47,8 @@ public long backoff(long attempts) {
         }
         double exp = Math.min(attempts, this.expMax);
         double term = initialInterval * Math.pow(multiplier, exp);
-        double randomFactor = ThreadLocalRandom.current().nextDouble(1 - jitter, 1 + jitter);
+        double randomFactor = jitter < Double.MIN_NORMAL ? 1.0 :

Review comment:
       `MIN_NORMAL` is 2^-1022, though.  So it certainly wouldn't affect someone setting jitter = 0.5.




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] mumrah commented on a change in pull request #10455: MINOR: Support ExponentialBackoff without jitter

Posted by GitBox <gi...@apache.org>.
mumrah commented on a change in pull request #10455:
URL: https://github.com/apache/kafka/pull/10455#discussion_r607313601



##########
File path: clients/src/main/java/org/apache/kafka/common/utils/ExponentialBackoff.java
##########
@@ -47,7 +47,8 @@ public long backoff(long attempts) {
         }
         double exp = Math.min(attempts, this.expMax);
         double term = initialInterval * Math.pow(multiplier, exp);
-        double randomFactor = ThreadLocalRandom.current().nextDouble(1 - jitter, 1 + jitter);
+        double randomFactor = jitter < Double.MIN_NORMAL ? 1.0 :

Review comment:
       I had to look this constant up :) 
   
   Can we just make it check if the jitter is equal to zero (or maybe `<=` zero)? A caller of this method setting jitter to something like 0.5 might be surprised that there is no jitter added.




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org