dcapwell commented on code in PR #4537:
URL: https://github.com/apache/cassandra/pull/4537#discussion_r2674158972
##########
src/java/org/apache/cassandra/config/RetrySpec.java:
##########
@@ -161,7 +164,9 @@ public static WaitStrategy toStrategy(SharedContext ctx,
RetrySpec spec)
{
if (!spec.isEnabled())
return WaitStrategy.None.INSTANCE;
- return RetryStrategy.parse(spec.baseSleepTime.toMilliseconds() + "ms *
2^attempts <= " + spec.maxSleepTime.toMilliseconds() + "ms,retries=" +
(spec.maxAttempts.value - 1), LatencySourceFactory.none());
+ RandomSource randomSource = RandomSource.wrap(ctx.random().get());
+ RetryStrategy.WaitRandomizer randomizer =
randomizers(randomSource).uniform();
+ return RetryStrategy.parse((int) (0.5 *
spec.baseSleepTime.toMilliseconds()) + "ms * 2^attempts ... " + (int) (1.5 *
spec.baseSleepTime.toMilliseconds()) + "ms * 2^attempts <= " +
spec.maxSleepTime.toMilliseconds() + "ms,retries=" + (spec.maxAttempts.value -
1), LatencySourceFactory.none(), randomizer);
Review Comment:
for better history: the logic in 5.0 is
https://github.com/apache/cassandra/blob/cassandra-5.0/src/java/org/apache/cassandra/utils/Backoff.java#L78
to simplify that logic its
```
baseSleepTime ^ (attempt - 1) * (rnd.double * 0.5)
```
But this new retry framework doesn't allow that same thing, so we have to do
things slightly differently...
` * (rnd.double * 0.5)` this adds jitter to the sleep, so to map this to the
new framework we need to have a `min` and `max` value and it will choose a
uniform value between those too; this change adds a min/max using the `...`
syntax and has `min * 0.5` and `max * 1.5` to keep the old behavior.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]