Repository navigation
Conversation
…me retries Zombie detection sends a TaskCallbackRequest while the TI is RUNNING, but the TI only leaves RUNNING once the DAG processor handles that request. The scheduler can therefore enqueue several requests for the same attempt. The first one moves the TI to UP_FOR_RETRY; each duplicate then calls handle_failure again, which sees the bumped try number and marks the TI FAILED, silently consuming the retry. In prod UK on 2026-11-19 this left ~50 lake-dms-cdc-fileloader-dag tasks (retries=1) FAILED after a metadb lock storm; they needed a manual clear. Make _execute_task_callbacks a no-op when the TI is no longer in the state and attempt (try_number) recorded in the request's SimpleTaskInstance. That covers both senders in 2.5.1: zombies (RUNNING) and killed-externally (QUEUED). Upstream fixed the duplicate-request case in Airflow 3.4.0 (apache#68008, closes apache#42553); 2.x, including 2.10.5, still has the bug. Co-Authored-By: Claude Opus 5.5 <[email protected]> Affirm-Session: 2a95b7fd-f6ac-49d8-aaf6-c568590e6efd
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.
Problem
Zombie detection (
SchedulerJob._find_zombies) sends aTaskCallbackRequestwhile the TI isRUNNING. The TI only leavesRUNNINGwhen the DAG processor handles that request, so the scheduler can enqueue several requests for the same attempt before the first is processed. The DAG processor then callshandle_failureonce per request:RUNNING, try 1 ≤ max_tries 1 →UP_FOR_RETRY.UP_FOR_RETRY, sotry_numberreads 2 > max_tries →FAILED. The retry is silently consumed.Prod UK, 2026-11-19. A metadb row-lock storm on
lake-dms-cdc-fileloader-dagmade ~70 tasks fail their final state commit after their work had already succeeded. The scheduler loggedDetected zombie job2–3× per TI, and the processor marked themUP_FOR_RETRY, thenFAILED. About 50 tasks withretries=1stayed FAILED until someone cleared them by hand ~80 min later. RC:~/1workspace/uk-fileloader-dagrun-lock-rc-2026-11-19.md(local).Fix
DagFileProcessor._execute_task_callbacksis now a no-op when the TI is no longer in the state and attempt (try_number) recorded in the request'sSimpleTaskInstance. It logsSkipping stale failure callback …instead.That covers both failure-callback senders in 2.5.1:
RUNNING._process_executor_events), created whileQUEUED.A request still matching the TI's current state and attempt is handled exactly as before.
Upstream
RUNNINGin the same scheduler pass and re-checks state under a row lock before purging.handle_failurein the processor, so the same patch would also be needed on the 2.9.3 line ([BATCH-4364] Port Affirm fork patches onto upstream 2.9.3 (2.9.3+affirm1) #35).Tests
Run on SQLite, Python 3.9,
apache-airflow==2.5.1constraints, fork code onPYTHONPATH.test_execute_on_failure_callbacks_skips_stale_request: stale request when the TI is alreadyup_for_retry/failed/success, or the next attempt isrunning. Assertshandle_failureis not called.test_duplicate_zombie_callbacks_do_not_consume_retry: unmocked. Two identical zombie requests for aretries=1TI must leave itUP_FOR_RETRY.tests/dag_processing/test_processor.py: 37 passed.tests/jobs/test_scheduler_job.py -k "zombie or callback or killed_externally": 23 passed.Not included
2.5.1+affirm4→affirm5) and no airflow-att image bump. Say if you want them here.🤖 Generated with Claude Code