Repository navigation
Conversation
|
Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide
|
eugeneo17
force-pushed
the
feat/53402-auto-clear-failed-tasks
branch
from
September 14, 2026 10:31
fa12a66 to
c4c565a
Compare
eugeneo17
force-pushed
the
feat/53402-auto-clear-failed-tasks
branch
2 times, most recently
from
September 24, 2026 12:02
b34ec5a to
e038c69
Compare
eugeneo17
added a commit
to CloudGeometry/airflow
that referenced
this pull request
Sep 25, 2026
Document the new Execution API version 2026-11-13 and the opt-in auto_clear_failed_tasks behavior on TriggerDagRunOperator. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Author
|
Hi, this PR implements #53402: an opt-in |
1 of 2 tasks
When TriggerDagRunOperator waits for a triggered child run (wait_for_completion=True) and that child fails, retrying the parent task previously dead-ended on DagRunAlreadyExists, or with reset_dag_run re-ran the entire child from scratch and discarded already-successful tasks. This adds an opt-in auto_clear_failed_tasks flag: on the parent task's retry it clears only the failed tasks (and their downstream) of the existing child run so the child resumes from its point of failure while preserving work that already succeeded. reset_dag_run keeps precedence when both are set. The failed-only clear is delivered server-side through a new Execution API version (2026-11-13); against an older core the operator raises rather than silently downgrading to a whole-run clear. Includes operator, task-SDK and execution-API unit tests, plus a regression test asserting the failed-only clear is reached when reset_dag_run=False (the gap that let the feature ship as a no-op). closes: apache#53402
Document the new Execution API version 2026-11-13 and the opt-in auto_clear_failed_tasks behavior on TriggerDagRunOperator. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
eugeneo17
force-pushed
the
feat/53402-auto-clear-failed-tasks
branch
from
October 15, 2026 07:17
6c39c95 to
5e3865d
Compare
This branch has not been deployed
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.
closes: #53402
TriggerDagRunOperator gains an opt-in auto_clear_failed_tasks flag (default False) that lets a parent-task retry resume a failed child run from its point of failure instead of dead-ending.
Motivation
Chained-DAG pipelines commonly pin the child's trigger_run_id (or its logical_date) so the child run is idempotent, one run per business date/key, so a parent retry doesn't spawn duplicate child runs. But with wait_for_completion=True, that same stability makes retries a dead end: once the pinned child run has failed, re-running the parent task raises DagRunAlreadyExists, and the only escape today is reset_dag_run=True, which wipes the whole child and re-runs tasks that already succeeded. There is no way to resume a failed child from where it stopped without manual cleanup.
What this does
On the parent task's retry, when the pinned child run already exists in a terminal failed state, auto_clear_failed_tasks=True clears only the failed tasks (and their downstream) of that run and re-runs them, preserving already-successful tasks - the child resumes rather than restarts or errors.
The failed-only clear is delivered server-side via a new Execution API version (2026-11-13, AddOnlyFailedToClearDagRunPayload); the only_failed flag is threaded operator → task-runner → supervisor → SDK client, and on a 409 conflict the client routes the trigger to the /clear endpoint with only_failed=true.
reset_dag_run keeps precedence: if both are set the whole run is cleared, and at most one clear ever happens.
It is version-gated, against a core older than 2026-11-13 the operator raises NotImplementedError rather than silently downgrading to a whole-run clear.
Scope and notes
Synchronous only (wait_for_completion=True); not supported with deferrable=True (setting both raises ValueError).
Because previously-successful child tasks are not re-run and failed ones are, the triggered DAG's tasks should be idempotent - called out in the operator docstring and the operator guide.
A healed child run's final state reads success, so run-level alerting won't see the transient failure (per-attempt logs are preserved). Emitting a metric/event when a heal fires would close that gap and is proposed as a follow-up rather than part of this PR.
Testing
Unit tests for the operator, the Task SDK (comms/supervisor/task-runner/client), and the Execution API version + payload. Includes a regression test asserting the failed-only clear is reached when reset_dag_run=False (the auto_clear path), which fails against a client that gates the clear on reset_dag_run alone.
Was generative AI tooling used to co-author this PR?
[X] Yes (please specify the tool below)
Generated-by: Claude Code (Opus 4.8) following the guidelines