rjgoyln opened a new pull request, #71194: URL: https://github.com/apache/airflow/pull/71194
## Summary A sensor running with `mode="reschedule"` is intermittently marked failed when the executor success for one poke reaches the scheduler after the task instance has already gone back to `scheduled` (or `queued`) for the next poke. The scheduler reads the late event as a task that finished without recording its own state, and fails it: ``` Executor CeleryExecutor(parallelism=512) reported that the task instance <TaskInstance: <dag_id>.<sensor_task_id> ... [scheduled] ti_id=...> finished with state success, but the task instance's state attribute is scheduled. ``` The existing guards for this race all assume the defer path. A reschedule exit leaves `next_method` unset and keeps the same `try_number`, so the executor key still matches and none of them apply. A reschedule row for the current try is the signal that separates the two cases: it says the worker exited `up_for_reschedule` rather than being killed. Anything with no such row still takes the externally-killed branch. It is resolved once per event batch alongside the bulk task-instance fetch, so the per-event path gains no query. closes: #71172 --- ##### Was generative AI tooling used to co-author this PR? - [X] Yes — Claude Code (Opus 5) Generated-by: Claude Code (Opus 5) following [the guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions) -- 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]
