[FLINK-40379][runtime] Wait for pre-restart parallelism to become available again after a rescale-triggered restart - #28999
Open
akalash wants to merge 2 commits into
Open
[FLINK-40379][runtime] Wait for pre-restart parallelism to become available again after a rescale-triggered restart#28999akalash wants to merge 2 commits into
akalash wants to merge 2 commits into
Conversation
…ilable again after a rescale-triggered restart Adds jobmanager.adaptive-scheduler.rescale.resource-stabilization-timeout, bounding how long the JobManager waits, after a rescale-triggered restart, for the pre-restart target parallelism to become available again from genuinely free slots before proceeding with whatever is sufficient. Previously, a restart triggered by a resource change would fall back to "sufficient resources" as soon as a single slot was free, even if the slots backing the just-cancelled execution had not been released yet, causing avoidable churn back to a lower parallelism.
…scheduler.rescale.resource-stabilization-timeout
akalash
commented
Aug 20, 2026
| new WaitingForResources.Factory( | ||
| this, | ||
| LOG, | ||
| settings.getSubmissionResourceWaitTimeout(), |
Contributor
Author
There was a problem hiding this comment.
Side note: It seems we use SubmissionResourceWaitTimeout for all cases - not only for submission. Perhaps we should follow-up on that with something like:
previousExecutionGraph == null
? settings.getSubmissionResourceWaitTimeout()
: Duration.ofMillis(-1L)
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
When the adaptive scheduler restarts a job to change its parallelism (a rescale), it previously fell back to "sufficient resources" as soon as a single slot became free — even if the slots backing the just-cancelled execution had not been released yet. This caused avoidable churn: the job would restart at a lower parallelism than what was actually about to become available, only to be rescaled again shortly after - in the worst case, when the slot is canceled by timeout(or failed during the cancellation), it can lead to an infinite restarting loop: (for 1 -> 2 scaling) JM sees 2 slots -> cancel the current execution -> one slot fail -> the job restart with 1 slot only -> JM sees 2 slots again -> ...
This pull request makes the JobManager wait, after a rescale-triggered restart, for the pre-restart target parallelism to become available again from genuinely free slots, bounded by a new configurable timeout, before proceeding with whatever is sufficient.
Brief change log
jobmanager.adaptive-scheduler.rescale.resource-stabilization-timeout, bounding how long the JobManager waits after a rescale-triggered restart for the pre-restart target parallelism to become available again.AdaptiveScheduler#goToWaitingForResourcesnow accepts the targetVertexParallelismof a restart and configures theWaitingForResourcesstate's stabilization phase with the new rescale timeout instead of the submission one when restarting.WaitingForResourcesgateshasDesiredResources()on the restart target parallelism (computed from genuinely free slots, excluding slots still reserved by the execution being cancelled) instead of the plain "sufficient resources" check, only for restarts with a known target.Restartingnow determines and passes through the target parallelism to restart with, viagetFreeSlotVertexParallelism()/getUpperBoundParallelism(...).Verifying this change
This change added tests and can be verified as follows:
AdaptiveSchedulerRescaleRestartTimingTest#testWaitingForResourcesDoesNotTransitionUntilFreeSlotsReachRescaleTargetverifies the scheduler keeps waiting until the restart target parallelism is reachable from free slots.AdaptiveSchedulerRescaleRestartTimingTest#testWaitingForResourcesFallsBackAfterRescaleResourceStabilizationTimeoutElapsesverifies the scheduler proceeds with whatever is sufficient once the new stabilization timeout elapses, rather than waiting forever.AdaptiveSchedulerFreeSlotVertexParallelismTest#testFreeSlotVertexParallelismExcludesReservedSlotsverifies free-slot-based parallelism calculation excludes slots still reserved by the execution being cancelled.AdaptiveSchedulerTest#testGoToWaitingForResourcesForRestartConfiguresStateTransitionManagerFactoryverifies the restart path configures the state transition manager with the rescale resource-stabilization timeout and skips the cooldown phase.WaitingForResourcesTest(e.g.testDesiredResourcesRequireReachingRestartTargetRegardlessOfBaseCheck,testDesiredResourcesCapRestartTargetToLatestResourceRequirements,testDesiredResourcesAreMetOnceFreeSlotParallelismReachesRestartTarget,testResourceTimeoutOverridesRestartTargetGuard) cover the new restart-target gating logic in isolation.CreatedTest,CreatingExecutionGraphTest, andRestartingTestwere extended to cover passing the restart target parallelism through the relevant state transitions.Does this pull request potentially affect one of the following parts:
@Public(Evolving): yes (a newConfigOptionwas added toJobManagerOptions, which is@PublicEvolving; purely additive, no existing options changed behavior)Documentation
Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Sonnet 5)