Andrushika opened a new pull request, #77335: URL: https://github.com/apache/airflow/pull/77335
## Why When a task defers or reschedules, the next run keeps the same task instance id. A different worker can pick up that next run. The Task SDK retries `PATCH /state` after a timeout or a 5xx. `ti_update_state` checks that the task instance is running, but not who sent the update. The heartbeat already checks the hostname and pid. So a retry from the earlier worker can land on the new run: 1. Worker A sends `PATCH /state` with `deferred`. The server commits it, but the response does not reach A. 2. The trigger fires, and worker B starts the same task instance with `PATCH /run`. 3. A retries the same `deferred` update. The server accepts it, because the task instance is running again. 4. The next heartbeat of B gets 409, and the supervisor kills the task of B. `up_for_reschedule` breaks the same way. I replayed these steps through the real routes on Postgres. On main, the retry in step 3 gets 204 and the heartbeat in step 4 gets 409. ## What The Task SDK sends its hostname and pid with every state update, like the heartbeat. If they do not match the task instance, the server returns 409 `running_elsewhere` and does not change the row. The supervisor of A already discards its outcome on a 409. Clients older than Execution API 2027-02-28 cannot send a hostname or pid, so their updates are not checked. --- ##### Was generative AI tooling used to co-author this PR? - [X] Yes (please specify the tool below) Generated-by: Claude Code (Opus 5.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]
