Repository navigation
[FLINK-41798][runtime] Fix long overflow in exponential-delay restart backoff - #30247
Open
cjohnson-confluent wants to merge 1 commit into
Open
cjohnson-confluent wants to merge 1 commit into
cjohnson-confluent wants to merge 1 commit into
Conversation
… backoff After enough restart attempts, the backoff plus a positive jitter overflowed to a negative value and was clamped to the initial backoff, so a job in a persistent failure loop alternated between the initial and the max backoff. With jitter-factor 1.0, offset + 1 overflowed and ThreadLocalRandom.nextLong threw IllegalArgumentException. Saturate the sum at Long.MAX_VALUE and avoid offset + 1 at Long.MAX_VALUE. Generated-by: Claude Opus 5.5
Collaborator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is the purpose of the change
After enough restart attempts,
ExponentialDelayRestartBackoffTimeStrategycomputes a backoff plus jitter that overflowslong. The negative result is clamped to the initial backoff, 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 + 1overflows andThreadLocalRandom.nextLongthrowsIllegalArgumentException.Brief change log
currentBackoffTime + jitteratLong.MAX_VALUEbefore clamping to the max backoff.offsetinstead ofoffset + 1when the jitter offset isLong.MAX_VALUE.Verifying this change
This change added tests and can be verified as follows:
testBackoffStaysAtMaxAfterManyAttempts: 200 attempts with initial 1 s, max 5 min, multiplier 2, jitter 0.1; from attempt 9 on the backoff must equal the max. Fails on master at attempt 53 (1000 instead of 300000).testFullJitterAfterManyAttempts: same with jitter 1.0; the backoff must stay within [initial, max]. ThrowsIllegalArgumentExceptionon master.Does this pull request potentially affect one of the following parts:
@Public(Evolving): noDocumentation
Was generative AI tooling used to co-author this PR?
Generated-by: Claude Opus 5.5