The GitHub Actions job "Tests" on 
airflow.git/fix-a/task_executed-twice_adopt_or_reset_orphaned_tasks has failed.
Run started by GitHub user mykola-shyshov (triggered by mykola-shyshov).

Head commit for run:
83c2840926eaed5b23a98f6ee3909e6ee118a167 / Mykola Shyshov 
<[email protected]>
fix: Prevent duplicate task execution on scheduler crash (Celery exec…
…utor)

Fixes #58570

## Problem

Tasks could execute twice when the scheduler crashed after a task was
queued to Celery but before the external_executor_id (Celery task ID)
was persisted to the database. This race condition occurred because:

1. Worker calls ti_run endpoint: state → RUNNING (external_executor_id still 
NULL)
2. Scheduler processes events in next cycle: sets external_executor_id
3. CRASH WINDOW: If scheduler crashes between steps 1-2, the task is
   left in RUNNING state but with NULL external_executor_id
4. On restart, adopt_or_reset_orphaned_tasks() cannot adopt the task
   (no executor ID to query Celery), so it resets the task
5. Task gets requeued while original execution is still running

Report URL: https://github.com/apache/airflow/actions/runs/19825456575

With regards,
GitHub Actions via GitBox


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to