Conversation
A sensor running with mode="reschedule" was intermittently marked failed when the executor success for one poke reached the scheduler after the task instance had already been put back for the next poke. The existing guards for this race only cover the defer path: a reschedule exit leaves next_method unset and does not bump try_number, so none of them applied and the event was treated as an external kill.
steveahnahn
left a comment
There was a problem hiding this comment.
Verified on Postgres with the source reverted to main and the new test kept, both params reproduce the bug (sensor marked failed) and with the fix both pass.
idx_task_reschedule_ti_id_id_desc covers the batched ti_id lookup, so it stays index-only as reschedule volume grows LGTM.
Thanks for review! Really appreciate it. |
|
Hello @rjgoyln - thank you for your contributions to Apache Airflow! The Airflow community has introduced a limit of 5 open pull requests at a time for contributors without write access to the repository. You currently have 24 open pull requests, so - as a one-time step of introducing the limit - we closed the ones where maintainers have not engaged yet:
These pull requests stay open because maintainers are already engaged in them - they count towards your limit:
This is not a judgement of you or of your changes. We never told contributors before that opening many pull requests at once was a problem, so there is nothing to feel bad about - and nothing is lost: your branches, commits and the review history stay where they are. What we ask you to do is to make your first prioritization decision: choose which of the pull requests above matter most to you, and reopen them (up to 5 open at a time, including the ones still open) with the "Reopen pull request" button or While your pull requests are waiting for review, the most valuable thing you can do is help in other ways - reviewing other contributors' pull requests, helping with issues, and taking part in the discussions on the devlist and Slack. Why we introduced the limit, what it means for you and how to reopen or restore a pull request is explained in https://github.com/apache/airflow/blob/main/contributing-docs/32_open_pull_request_limit.rst. Drafted-by: Claude Code (Opus 5); reviewed by @potiuk before posting |
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 toscheduled(orqueued) for the next poke. The scheduler reads the late event as a task that finished without recording its own state, and fails it:The existing guards for this race all assume the defer path. A reschedule exit leaves
next_methodunset and keeps the sametry_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 exitedup_for_reschedulerather 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?
Generated-by: Claude Code (Opus 5) following the guidelines