Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong multiplier value in retry delay function example #622

Open
zerda opened this issue Aug 8, 2023 · 0 comments
Open

Wrong multiplier value in retry delay function example #622

zerda opened this issue Aug 8, 2023 · 0 comments
Labels
good first issue Good for newcomers

Comments

@zerda
Copy link

zerda commented Aug 8, 2023

Hi, there is a typo in the README.md file at 11.1. Retry Delay Function.

final double multiplier = 0.5;
final int baseDelaySecond = 1;

ParallelConsumerOptions.<String, String>builder()
        .retryDelayProvider(recordContext -> {
            int numberOfFailedAttempts = recordContext.getNumberOfFailedAttempts();
            long delayMillis = (long) (baseDelaySecond * Math.pow(multiplier, numberOfFailedAttempts) * 1000);
            return Duration.ofMillis(delayMillis);
        });

While the multiplier is set to 0.5, it results in delay being always less than 1s, and decreasing at every call. This does not adhere to the exponential backoff strategy.

Failed Attempts Delay (ms)
1 1*0.5^1*1000 = 500
2 1*0.5^2*1000 = 250
3 1*0.5^3*1000 = 125
@rkolesnev rkolesnev added the good first issue Good for newcomers label Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants