seanmuth opened a new pull request, #73142:
URL: https://github.com/apache/airflow/pull/73142

   `Supervisor.final_state` gated on `self._exit_code == 0` before ever 
consulting `self._terminal_state`. `wait()` defaults an unobserved exit code to 
`1` if `_monitor_subprocess()`'s loop exits (all sockets drained/closed) before 
`_check_subprocess_exit`'s non-blocking poll happens to observe the real exit 
code -- a race that widens under scheduling delay. When that happens, an 
already-confirmed terminal state reported by the subprocess (e.g. 
`SucceedTask`) gets discarded in favor of a state re-derived from the wrong, 
defaulted exit code, landing outside `STATES_SENT_DIRECTLY` and triggering a 
redundant `update_task_state_if_needed()` -> `.finish()` call that 409s against 
the DB row a prior `.succeed()` call already wrote correctly -- crashing task 
supervision and leaving the task incorrectly marked `up_for_retry` even though 
it had already succeeded.
   
   Fix: trust `self._terminal_state` whenever the subprocess actually reported 
one, independent of whether the exit code was genuinely observed or defaulted. 
Only fall back to deriving the state from the exit code when no terminal 
message was ever received. This is a one-line reordering of `final_state`'s 
existing branches, purely local, no additional network/DB round-trip.
   
   Root-caused via a live instrumented burst-fanout repro (full write-up in the 
linked issue comment); this addresses the underlying ordering bug rather than 
only swallowing its symptom (the separate, already-merged #63355 idempotency 
check on the API side remains a good complementary hardening).
   
   closes: #65708
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes — Claude Sonnet 5
   
   Generated-by: Claude Sonnet 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]

Reply via email to