PCTEJA commented on code in PR #77290:
URL: https://github.com/apache/airflow/pull/77290#discussion_r4734993501


##########
airflow-core/src/airflow/jobs/triggerer_job_runner.py:
##########
@@ -961,6 +989,17 @@ def run_context(self) -> Iterator[None]:
         """Wrap the run loop. Subclasses can override to install 
setup/teardown."""
         yield
 
+    def kill(self, *args: Any, **kwargs: Any) -> None:
+        """Terminate the subprocess, then drain pending log uploads."""
+        try:
+            super().kill(*args, **kwargs)
+        finally:
+            # kill() is the last point that services subprocess requests, so a
+            # finished-trigger message can still arrive until it returns. Drain
+            # the pool only once it has, or a late finalize_trigger_log would
+            # submit to a shut-down executor and lose the log.
+            self._log_upload_executor.shutdown(wait=True)

Review Comment:
   Good catch, and thanks for running it end to end. The 57 s down to under 5 s 
result with all 300 logs uploaded is exactly what I was hoping for.
   
   Fixed in c48e5c0f: kill() now takes the signal explicitly, and on SIGKILL 
the pool is shut down with wait=False and cancel_futures=True, so a second 
signal drops the queue instead of draining it. The normal shutdown path still 
drains, so a finished trigger message arriving during a graceful kill still 
uploads. One trade-off to flag: queued uploads dropped on a forced exit are not 
uploaded at all. The files stay on disk, but nothing re-uploads them later, 
which seemed the right price for an exit the operator explicitly forced.
   
   New test test_kill_with_sigkill_drops_queued_log_uploads covers it: all four 
workers blocked, one upload queued, and kill(SIGKILL) returns without waiting 
and the queued upload never runs. It fails on the previous head.
   
   Drafted-by: ChatGPT Astra
   



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