You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using DelayBackoffType.Exponential retry startegy in combination with MaxDelay eventually leads to "infinite" wait.
Delay computing method ignores MaxDelay in case of OverflowException and that leads to wait TimeSpan.MaxValue instead of MaxDelay
Expected behavior
When retry delay computing leads to TimeSpanOverflowException and a MaxDelay is defined, MaxDelay should be used.
Actual behavior
When retry delay computing leads to TimeSpanOverflowException, the applied Delay is TimeSpan.MaxValue regardless a MaxDelay is defined or not.
Steps to reproduce
Consider following retry strategy setup
newRetryStrategyOptions<bool>(){OnRetry= args =>{_logger.LogWarning("(Key: {OperationKey}) attempt {AttemptCount} failed after {AttemptDuration}ms, next attempt will take place in {RetryDelay}s",args.Context.OperationKey,args.AttemptNumber,args.Duration.TotalMilliseconds,args.RetryDelay.TotalSeconds);returnnewValueTask();},Delay=TimeSpan.FromSeconds(2),BackoffType=DelayBackoffType.Exponential,MaxDelay=TimeSpan.FromMinutes(5),MaxRetryAttempts=int.MaxValue};
Observation in logs
Executing a pipeline base on this startegy leads to inconsistent behavior after the attempt 39, as I've observed in my logs:
(Key: 159e42ca-e781-48a8-927d-418b4ce8a811) attempt 0 failed after 1061.6031ms, next attempt will take place in 2s
(Key: 159e42ca-e781-48a8-927d-418b4ce8a811) attempt 1 failed after 248.2402ms, next attempt will take place in 4s
...
(Key: 159e42ca-e781-48a8-927d-418b4ce8a811) attempt 7 failed after 320.1541ms, next attempt will take place in 256s
(Key: 159e42ca-e781-48a8-927d-418b4ce8a811) attempt 8 failed after 950.9286ms, next attempt will take place in 300s
...
(Key: 159e42ca-e781-48a8-927d-418b4ce8a811) attempt 38 failed after 294.6921ms, next attempt will take place in 300s
(Key: 159e42ca-e781-48a8-927d-418b4ce8a811) attempt 39 failed after 298.6555ms, next attempt will take place in 922337203685.4775s
Describe the bug
Using
DelayBackoffType.Exponential
retry startegy in combination withMaxDelay
eventually leads to "infinite" wait.Delay computing method ignores
MaxDelay
in case of OverflowException and that leads to waitTimeSpan.MaxValue
instead ofMaxDelay
Expected behavior
When retry delay computing leads to
TimeSpan
OverflowException
and aMaxDelay
is defined,MaxDelay
should be used.Actual behavior
When retry delay computing leads to
TimeSpan
OverflowException
, the applied Delay isTimeSpan.MaxValue
regardless aMaxDelay
is defined or not.Steps to reproduce
Consider following retry strategy setup
Observation in logs
Executing a pipeline base on this startegy leads to inconsistent behavior after the attempt 39, as I've observed in my logs:
Exception(s) (if any)
No response
Polly version
8.0.0
.NET Version
net7.0
Anything else?
Investigation
In https://github.com/App-vNext/Polly/blob/main/src/Polly.Core/Retry/RetryHelper.cs RetryHelper.GetRetryDelay() has been updated with Introduce
RetryStrategyOptions.MaxDelay
property #1620But
OverflowException
handling introduced with commit 3dd6a7a has not been updated to take newMaxDelay
property in account.The text was updated successfully, but these errors were encountered: