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

Retryable with exponential backoff not working with delayExpression #397

Closed
mreichenbach-igniti opened this issue Nov 1, 2023 · 3 comments
Labels
Milestone

Comments

@mreichenbach-igniti
Copy link

mreichenbach-igniti commented Nov 1, 2023

Hi,

I tried to use the @Retryable annotation in spring boot with a configurable delay and exponential backoff. This is how I tried it:

@Retryable(
    maxAttemptsExpression = "3",
    backoff = @Backoff(delayExpression = "600", multiplier = 2, maxDelay = 10000)
)

The maxAttemptsExpression and delayExpression are actually filled with environment variables via "${...}"

Expected: exponential delay as described in the documentation

Actual: constant delay of 600ms

When I change it to delay = 600 then it's working as expected. I checked it with spring-retry 2.0.4

Thanks for having a look!
Regards, Michael

@R-Zer0
Copy link
Contributor

R-Zer0 commented Nov 7, 2023

Same with spring retry 2.0.3 for me

Noticed that in the ExponentialBackOffContext when we are calling getSleepAndIncrement
sleep value resolved from intervalSupplier if it is not null. But further when we resolving getNextInterval, we assigning it to the interval instead of intervalSupplier and interval keep it initial value for the next iteration.

		public synchronized long getSleepAndIncrement() {
			long sleep = getInterval();
			long max = getMaxInterval();
			if (sleep > max) {
				sleep = max;
			}
			else {
				this.interval = getNextInterval();
			}
			return sleep;
		}

@artembilan
Copy link
Member

@mreichenbach-igniti , @R-Zer0 ,

if you see how that can be fixed, feel free to raise a respective Pull Request.

Thanks

@R-Zer0
Copy link
Contributor

R-Zer0 commented Nov 8, 2023

@artembilan #399

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants