anmolxlight opened a new pull request, #72767: URL: https://github.com/apache/airflow/pull/72767
Fixes #72716. ## What happened When a deferrable task defers, the worker exits cleanly and the executor records a SUCCESS event for that try. If the trigger resumes the TI and the resumed attempt reaches RUNNING before the scheduler drains that stale event, `process_executor_events` logs `state mismatch` and fails the TI via `handle_failure`. ## Why the existing guard misses it The resume-after-defer guard added for #66374 (#66431) and extended for #67287 (#68741) only covers `SCHEDULED`/`QUEUED` with `next_method` set. Two facts about the RUNNING variant: - `next_method` survives trigger resume, queueing, and the QUEUED to RUNNING transition (it is only cleared on terminal, retry, and reschedule updates), so it still identifies the try as defer-resumed. - In the new executor workload API nothing re-adds a picked-up workload to executor bookkeeping (`running` is only removed from, never added to), so `executor.has_task(ti)` is False for the whole RUNNING duration and cannot tell the stale event apart. A same-try SUCCESS for a RUNNING TI with `next_method` set can therefore only be the stale defer-exit event (or the harmless completion race, which needs no action), never an external kill, so it is now treated as requeued. RUNNING without `next_method` still goes through the mismatch path. ## Test plan - New `test_process_executor_events_stale_success_when_running_after_defer`: fails before the fix (state mismatch path), passes after; also asserts the `next_method=None` negative still emits `scheduler.tasks.killed_externally`. - Existing `..._when_scheduled_after_defer`, `..._when_queued_after_defer`, and `..._ti_requeued` all pass. - `prek run ruff` and `prek run ruff-format` pass on changed files. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
