ashb commented on code in PR #73249:
URL: https://github.com/apache/airflow/pull/73249#discussion_r4074911098


##########
task-sdk/src/airflow/sdk/execution_time/supervisor.py:
##########
@@ -1585,23 +1576,18 @@ def wait(self) -> int:
         return self._exit_code
 
     def update_task_state_if_needed(self):
-        # If a direct-state API call (succeed / retry / defer / reschedule)
-        # was attempted but raised, `_pending_terminal_state_msg` still holds
-        # the original request. Re-issue the matching dedicated API call so
-        # the server learns the terminal state we couldn't deliver earlier.
-        # Without this recovery, a transient API failure during the direct
-        # call would leave the TI stuck RUNNING on the server — `finish()`
-        # cannot substitute because the server-side `finish` endpoint does
-        # not accept SUCCESS / DEFERRED / SERVER_TERMINATED transitions.
+        if self._terminal_state == SERVER_TERMINATED:
+            self._pending_terminal_state_msg = None
+            return
+
         if self._pending_terminal_state_msg is not None:
-            self._replay_pending_terminal_state_msg()
+            if isinstance(self._pending_terminal_state_msg, TaskState):
+                self._send_terminal_state_msg(self._pending_terminal_state_msg)
+            else:
+                self._replay_pending_terminal_state_msg()
             return
 
-        # If the process has finished in a non-directly-patched state (e.g.
-        # FAILED, or SKIPPED reported via a TaskState message), `finish()` is
-        # the dedicated endpoint for those transitions. For states already in
-        # STATES_SENT_DIRECTLY whose direct API call succeeded, no further
-        # action is needed.
+        # A process can exit before sending an outcome; report the inferred 
state.

Review Comment:
   Yes, i already have a separate change to fix this. Not doing it as part of 
this pr



-- 
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