You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "eugeneo17 (via GitHub)" <gi...@apache.org> on 2026/08/17 17:52:25 UTC

[PR] Add auto-clear of failed child tasks to TriggerDagRunOperator (#53402) [airflow]

eugeneo17 opened a new pull request, #71730:
URL: https://github.com/apache/airflow/pull/71730

   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](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add auto-clear of failed child tasks to TriggerDagRunOperator (#53402) [airflow]

Posted by "eugeneo17 (via GitHub)" <gi...@apache.org>.
eugeneo17 commented on PR #71730:
URL: https://github.com/apache/airflow/pull/71730#issuecomment-6059688246

   Hi, this PR implements #53402: an opt-in `auto_clear_failed_tasks` flag for `TriggerDagRunOperator` (default `False`), so a parent retry can resume a failed child run instead of dead-ending. I've just merged the latest `main` (no conflicts). It's my first contribution here, so the CI workflows need approval to run. Could a committer approve them and take a look when there's time? Happy to adjust anything.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add auto-clear of failed child tasks to TriggerDagRunOperator (#53402) [airflow]

Posted by "boring-cyborg[bot] (via GitHub)" <gi...@apache.org>.
boring-cyborg[bot] commented on PR #71730:
URL: https://github.com/apache/airflow/pull/71730#issuecomment-5318356450

   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](https://github.com/apache/airflow/blob/main/contributing-docs/README.rst)
   Here are some useful points:
   - Pay attention to the quality of your code (ruff, mypy and type annotations). Our [prek-hooks]( https://github.com/apache/airflow/blob/main/contributing-docs/08_static_code_checks.rst#prerequisites-for-prek-hooks) will help you with that.
   - In case of a new feature add useful documentation (in docstrings or in `docs/` directory). Adding a new operator? Check this short [guide](https://github.com/apache/airflow/blob/main/airflow-core/docs/howto/custom-operator.rst) Consider adding an example Dag that shows how users should use it.
   - Consider using [Breeze environment](https://github.com/apache/airflow/blob/main/dev/breeze/doc/README.rst) for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
   - Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
   - Please follow [ASF Code of Conduct](https://www.apache.org/foundation/policies/conduct) for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
   - Be sure to read the [Airflow Coding style]( https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#coding-style-and-best-practices).
   - Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits.
   Apache Airflow is a community-driven project and together we are making it better 🚀.
   In case of doubts contact the developers at:
   Mailing List: dev@airflow.apache.org
   Slack: https://s.apache.org/airflow-slack
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add auto-clear of failed child tasks to TriggerDagRunOperator (#53402) [airflow]

Posted by "pierrejeambrun (via GitHub)" <gi...@apache.org>.
pierrejeambrun closed pull request #71730: Add auto-clear of failed child tasks to TriggerDagRunOperator (#53402)
URL: https://github.com/apache/airflow/pull/71730


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org