Skip to content

decorrelatedJitter and fullJitter delay calculation overflows #2115

@kgrits

Description

@kgrits

Bug Report

Current Behavior

  1. Delay.decorrelatedJitter() always returns the same value. If used with default setup - 0.

  2. I couldn't find any limitation on attempts in ConnectionWatchdog, that's why I decided to test Delay.fullJitter() with a high number of attempts (100+). If I use any other value for base except the default one I get IllegalArgumentException: bound must be greater than origin.

Stack trace
Exception in thread "main" java.lang.IllegalArgumentException: bound must be greater than origin
	at java.base/jdk.internal.util.random.RandomSupport.checkRange(RandomSupport.java:246)
	at java.base/java.util.random.RandomGenerator.nextLong(RandomGenerator.java:739)
	at java.base/java.util.concurrent.ThreadLocalRandom.nextLong(ThreadLocalRandom.java:484)
	at io.lettuce.core.resource.Delay.randomBetween(Delay.java:331)
	at io.lettuce.core.resource.FullJitterDelay.createDelay(FullJitterDelay.java:57)

Input Code

decorrelatedJitter
Delay delay = Delay.decorrelatedJitter().get();
for (int i = 0; i < 10; i++) {
    System.out.println(delay.createDelay(i).toMillis());
}
fullJitter
var delay = Delay.fullJitter(Duration.ZERO, Duration.ofSeconds(30), 2, TimeUnit.MILLISECONDS);
for (int i = 0; i < 100; i++) {
    System.out.println(delay.createDelay(i).toMillis());
}

Expected behavior/code

Environment

  • Lettuce version(s): 6.1.8.RELEASE
  • Redis version: N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions