Chris Johnson created FLINK-41798:
-------------------------------------

             Summary: Exponential-delay restart backoff overflows after many 
attempts and drops to the initial backoff
                 Key: FLINK-41798
                 URL: https://issues.apache.org/jira/browse/FLINK-41798
             Project: Flink
          Issue Type: Bug
            Reporter: Chris Johnson


{{ExponentialDelayRestartBackoffTimeStrategy.calculateActualBackoffTime()}} 
casts {{initialBackoffMS * Math.pow(backoffMultiplier, currentRestartAttempt)}} 
to long and adds a random jitter. After enough attempts the sum overflows, and 
soon after the cast itself saturates at {{{}Long.MAX_VALUE{}}}. Then:
 * {{currentBackoffTime + jitter}} overflows for a large enough positive 
jitter, {{Math.min}} keeps the negative value, and {{Math.max}} returns 
{{{}initialBackoffMS{}}}. With jitter-factor 0.1 this happens for about half of 
the restarts, so a job that keeps failing alternates between the initial and 
the max backoff instead of staying at the max.
 * With jitter-factor 1.0, {{offset + 1}} in {{calculateJitterBackoffMS}} 
overflows and {{ThreadLocalRandom.nextLong }}throws 
{{{}IllegalArgumentException{}}}.

The attempt counter only resets after {{reset-backoff-threshold}} without 
failures, so a job in a failure loop stays in this state once it reaches it. 
With the defaults (initial 1 s, max 1 min, multiplier 1.5, jitter-factor 0.1) 
that is around attempt 90, about 1.4 hours into the loop.

Repro: a unit test with a {{ManualClock}} that calls {{notifyFailure}} 200 
times, advancing the clock by the returned backoff each time (initial 1 s, max 
5 min, multiplier 2, jitter 0.1). From attempt 53 on, about half of the 
backoffs are 1 s.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to