Document when a retry policy is not consulted - #70813
Closed
1fanwang wants to merge 1 commit into
Closed
Conversation
A retry policy is evaluated from a caught exception inside the task worker process, so it does not apply when that process is terminated without raising one: an external kill, a node drain, a spot-instance reclaim or the OOM killer. Those attempts fall through to the standard retries count, which is easy to miss when reading the current docs. Record the boundary alongside the existing AirflowFailException note and in the RetryPolicy docstring. Signed-off-by: 1fanwang <1fannnw@gmail.com>
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.
Retry policies are documented as running in the task worker process, but the consequence of that is easy to miss. The policy is evaluated from a caught exception, so a failure where the worker process never raises one is not covered: an external kill, a node drain, a spot-instance reclaim, the OOM killer. Those attempts fall through to the standard
retriescount.The design is reasonable and the docs already say where the policy runs. What they do not say is what happens when there is no exception to hand it. On preemptible or spot capacity that is the common failure mode rather than an edge case, and a policy written as
RetryRule(exception=..., action=RetryAction.FAIL)looks like it is simply being ignored.This records the boundary in two places: a row in the "Composition with existing parameters" table next to the existing
AirflowFailExceptionnote, and theRetryPolicydocstring. Docs only, no behaviour change.Testing
Same
ExceptionRetryPolicyon two tasks, bothretries=3. The policy fails everything immediately, so if it is consulted the task must end on try 1. Run on 3.4.0 against a real deployment (api-server + scheduler + LocalExecutor, task in a supervised subprocess), not a mocked runner.policy_raisesraise ConnectionError(...)failedpolicy_worker_killedos.kill(os.getpid(), SIGKILL)failedIdentical policy, opposite outcome, decided entirely by how the worker died.
Raw logs
Task body used for the termination case:
Exception case, policy consulted and honoured:
Termination case, policy never consulted across all four attempts:
The first attempt log is zero bytes, since the process died before flushing:
Scheduler side, the retries are spent and the policy never gets a say:
Was generative AI tooling used to co-author this PR?