Respect retries when a deferrable trigger ends a task with TaskFailedEvent - #69821
Merged
vatsrahul1001 merged 3 commits intoAug 5, 2026
Merged
Conversation
…Event When a deferrable operator's trigger yields a terminal TaskFailedEvent, the task was always marked failed and on_failure_callback ran, even with retries remaining. A worker-side failure with retries left instead goes up_for_retry and runs on_retry_callback. Route trigger-emitted failures through TaskInstance.handle_failure (the path the scheduler has used since apache#56586) so retry-eligibility is respected and the callback runs on_retry_callback vs on_failure_callback accordingly. closes: apache#69819 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
hkc-8010
force-pushed
the
fix/deferred-task-failed-event-respects-retries
branch
from
July 13, 2026 11:17
4017af8 to
5dfb1ce
Compare
hkc-8010
marked this pull request as ready for review
July 13, 2026 12:17
kaxil
reviewed
Jul 30, 2026
amoghrajesh
reviewed
Aug 4, 2026
amoghrajesh
left a comment
Contributor
There was a problem hiding this comment.
Code looks ok, but I have a qn, seems to be spillover from past version of the PR
eladkal
approved these changes
Aug 5, 2026
Contributor
Backport failed to create: v3-3-test. View the failure log Run detailsNote: As of Merging PRs targeted for Airflow 3.X In matter of doubt please ask in #release-management Slack channel.
You can attempt to backport this manually by running: cherry_picker dd1f84a v3-3-testThis should apply the commit to the v3-3-test branch and leave the commit in conflict state marking After you have resolved the conflicts, you can continue the backport process by running: cherry_picker --continueIf you don't have cherry-picker installed, see the installation guide. |
1 task
vatsrahul1001
added a commit
that referenced
this pull request
Aug 5, 2026
…Event (#69821) (#71163) * Respect retries when a deferrable trigger ends a task with TaskFailedEvent When a deferrable operator's trigger yields a terminal TaskFailedEvent, the task was always marked failed and on_failure_callback ran, even with retries remaining. A worker-side failure with retries left instead goes up_for_retry and runs on_retry_callback. Route trigger-emitted failures through TaskInstance.handle_failure (the path the scheduler has used since #56586) so retry-eligibility is respected and the callback runs on_retry_callback vs on_failure_callback accordingly. closes: #69819 * Preserve retry history for trigger-ended deferred failures * Fix stale trigger callback comment --------- (cherry picked from commit dd1f84a) Co-authored-by: Hemkumar Chheda <95332229+hkc-8010@users.noreply.github.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 task
vatsrahul1001
added a commit
that referenced
this pull request
Aug 5, 2026
…Event (#69821) (#71163) * Respect retries when a deferrable trigger ends a task with TaskFailedEvent When a deferrable operator's trigger yields a terminal TaskFailedEvent, the task was always marked failed and on_failure_callback ran, even with retries remaining. A worker-side failure with retries left instead goes up_for_retry and runs on_retry_callback. Route trigger-emitted failures through TaskInstance.handle_failure (the path the scheduler has used since #56586) so retry-eligibility is respected and the callback runs on_retry_callback vs on_failure_callback accordingly. closes: #69819 * Preserve retry history for trigger-ended deferred failures * Fix stale trigger callback comment --------- (cherry picked from commit dd1f84a) Co-authored-by: Hemkumar Chheda <95332229+hkc-8010@users.noreply.github.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.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.
Summary
When a deferrable operator's trigger yields a terminal
TaskFailedEvent, the task was always markedfailedand itson_failure_callbackran, even when the task still had retries remaining. A worker-side failure with retries left instead goesup_for_retryand runson_retry_callback. This makes trigger-driven failures behave the same way.The
BaseTaskEndEventhandler inairflow-core/src/airflow/models/trigger.pynow, for aFAILEDevent, loads the serialized task and routes throughTaskInstance.handle_failure(), the same path the scheduler executor-event handling has used since #56586.handle_failuresetsup_for_retryorfailedbased on retry-eligibility and fires theon_task_instance_failedlistener, failure metrics, and a Log entry. The callback request now carries the resolvedtask_callback_typeso the DAG processor runson_retry_callbackvson_failure_callbackcorrectly.TaskSuccessEventandTaskSkippedEventare unchanged.closes: #69819
Changes
airflow-core/src/airflow/models/trigger.py: route trigger-emitted failures throughhandle_failure, thread the retry-awaretask_callback_typeinto the callback, and skip the xcom push on the retry path.airflow-core/tests/unit/models/test_trigger.py: new parametrized test covering the retry-eligible case (up_for_retry+on_retry_callback+on_task_instance_failedlistener) and the exhausted case (failed+on_failure_callback); the existing end-event test now sets a realisticstart_date(a deferred task has already run).airflow-core/newsfragments/69821.bugfix.rst.Testing
pytest airflow-core/tests/unit/models/test_trigger.py(39 passed).main(the task staysfailedand the callback is routed as a failure) and passes with this change.This change was written with AI assistance (Claude); the author reviewed the diff and reproduction.