Skip to content

[v3-3-test] Fix scheduler firing on_failure_callback for heartbeat-timed-out retries (#66767)#69824

Merged
eladkal merged 1 commit into
v3-3-testfrom
backport-f2403cc-v3-3-test
Jul 13, 2026
Merged

[v3-3-test] Fix scheduler firing on_failure_callback for heartbeat-timed-out retries (#66767)#69824
eladkal merged 1 commit into
v3-3-testfrom
backport-f2403cc-v3-3-test

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

When a worker stops heartbeating (OOMKill, node eviction), the scheduler's
_purge_task_instances_without_heartbeats built a TaskCallbackRequest
without task_callback_type. The Dag processor's task-callback dispatch
branches on that field: UP_FOR_RETRY runs on_retry_callback, anything
else (including None) runs on_failure_callback. So heartbeat-timeout
cleanup always fired on_failure_callback even when the task still had
retries remaining, producing spurious failure alerts for tasks that
ultimately succeeded on retry.

Set task_callback_type from ti.is_eligible_to_retry(), the canonical
retry-eligibility predicate, guarded by max_tries > 0. The guard covers
the one gap the predicate has here: this path doesn't load ti.task, so the
predicate falls back to try_number <= max_tries and drops the
retries-configured check its task-loaded branch applies. Deferring to the
predicate also keeps a RESTARTING task (cleared while running) retry-
eligible past max_tries, where a hand-rolled try_number <= max_tries
check would have fired on_failure_callback.

closes: #65400
(cherry picked from commit f2403cc)

Co-authored-by: Stefan Wang 1fannnw@gmail.com
Signed-off-by: 1fanwang 1fannnw@gmail.com
Co-authored-by: kimhaggie kimhaggie@gmail.com

…med-out retries (#66767)

When a worker stops heartbeating (OOMKill, node eviction), the scheduler's
``_purge_task_instances_without_heartbeats`` built a ``TaskCallbackRequest``
without ``task_callback_type``. The Dag processor's task-callback dispatch
branches on that field: ``UP_FOR_RETRY`` runs ``on_retry_callback``, anything
else (including ``None``) runs ``on_failure_callback``. So heartbeat-timeout
cleanup always fired ``on_failure_callback`` even when the task still had
retries remaining, producing spurious failure alerts for tasks that
ultimately succeeded on retry.

Set ``task_callback_type`` from ``ti.is_eligible_to_retry()``, the canonical
retry-eligibility predicate, guarded by ``max_tries > 0``. The guard covers
the one gap the predicate has here: this path doesn't load ``ti.task``, so the
predicate falls back to ``try_number <= max_tries`` and drops the
retries-configured check its task-loaded branch applies. Deferring to the
predicate also keeps a ``RESTARTING`` task (cleared while running) retry-
eligible past ``max_tries``, where a hand-rolled ``try_number <= max_tries``
check would have fired ``on_failure_callback``.

closes: #65400
(cherry picked from commit f2403cc)

Co-authored-by: Stefan Wang <1fannnw@gmail.com>
Signed-off-by: 1fanwang <1fannnw@gmail.com>
Co-authored-by: kimhaggie <kimhaggie@gmail.com>
@boring-cyborg boring-cyborg Bot added the area:Scheduler including HA (high availability) scheduler label Jul 13, 2026
@eladkal eladkal marked this pull request as ready for review July 13, 2026 11:48
@eladkal eladkal requested review from XD-DENG and ashb as code owners July 13, 2026 11:48
@eladkal eladkal merged commit afeb272 into v3-3-test Jul 13, 2026
100 of 109 checks passed
@eladkal eladkal deleted the backport-f2403cc-v3-3-test branch July 13, 2026 12:43
@github-actions github-actions Bot added this to the Airflow 3.3.1 milestone Jul 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor Author

Hi maintainer, this PR was merged without a milestone set.
We've automatically set the milestone to Airflow 3.3.1 based on: bug fix merged to version branch
If this milestone is not correct, please update it to the appropriate milestone.

This comment was generated by Milestone Tag Assistant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:Scheduler including HA (high availability) scheduler

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants