Skip to content

ExponentialRandomBackOffPolicy not always random #391

Closed
@bones418

Description

@bones418

Hey all,

Great work on this project. Reaching out because I feel like the documentation is a bit unclear as to what happens in the following case:

@Backoff(delay = 2000, multiplier = 1.0, random = true))

You'd think you're introducing randomness here by setting random to true, but this is not the case. Refer to this line https://github.com/spring-projects/spring-retry/blob/v2.0.4/src/main/java/org/springframework/retry/backoff/ExponentialRandomBackOffPolicy.java#L79

next = (long) (next * (1 + r.nextFloat() * (getMultiplier() - 1)));

When multiplier is 1.0 that line of code basically boils down to next = next. This doesn't create randomness and allows a thundering herd problem to persist. At the very least, can the documentation be more clear that random should be used with multiplier values greater than 1.0. Even better, can multiplier = 1.0 and random = true just be flagged and raised as an invalid configuration?

Thanks!
John

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions