Matthew-DWM opened a new pull request, #9364:
URL: https://github.com/apache/texera/pull/9364

   ### What changes were proposed in this PR?
   
   When a Python UDF worker's process dies, never connects, or is busy for over 
5 s, the engine never finds out: the execution stays `RUNNING` (or 
"Submitting") forever with no error. Four causes, all in `pythonworker/`:
   
   - **Nothing watched the process.** A daemon thread now waits for the Python 
process to exit and, unless the worker is stopping it, fails the worker with 
the exit code (137 adds "killed by SIGKILL, often the out-of-memory killer"). 
Python now writes straight to the JVM's stdout/stderr, so the exit is seen even 
while a child it started keeps those streams open.
   - **Flight client errors were dropped.** `startProxyClient` discarded the 
client task's `Future`. The task now reports any exception, and the worker 
fails with it (or with the exit code if the process is gone).
   - **An ack slower than 5 s ended the client.** `poll(5, SECONDS)` returned 
`null` and the NPE was dropped, so a worker that was only busy (e.g. holding 
the GIL) hung the run. The client used to wait for each ack with no limit; the 
5s poll is what introduced this hang. The client now waits with `read()` (the 
watcher catches a dead process), then checks the put's final status, so a put 
that fails after its ack, or ends without one, stops the client with that error.
   - **The port handshake ignored an early exit.** A process that died before 
reporting its port (e.g. missing packages) blocked the actor in `preStart` 
forever. `awaitPythonPort()` now waits while checking the process is alive, and 
fails with the exit code.
   
   Each failure is a `WorkflowRuntimeException` naming the worker, so it takes 
the existing path to FAILED and the error tab.
   
   ```
   Before:  SIGKILL mid-run         -> RUNNING forever, no error
   After:   SIGKILL mid-run         -> FAILED within 0.1 s, "... exited 
unexpectedly with code 137 (...)"
   Before:  UDF holds the GIL > 5 s -> run hangs (races with stats polling)
   After:   UDF holds the GIL > 5 s -> completes
   Before:  worker dies at import   -> "Submitting" forever
   After:   worker dies at import   -> FAILED within ~3 s, "... exited with 
code 1 before connecting to the engine"
   ```
   
   #### Before (main)
   
   <img width="1440" height="740" alt="before-kill" 
src="https://github.com/user-attachments/assets/e7dd92d2-f291-49ff-8cf5-661964eb07d1";
 />
   <img width="1440" height="740" alt="before-earlyexit" 
src="https://github.com/user-attachments/assets/c009c390-0a9f-40e9-823b-d73b56ab5c08";
 />
   
   #### After (this PR)
   
   <img width="1440" height="765" alt="after-kill" 
src="https://github.com/user-attachments/assets/58836a90-4cc3-4251-a6ee-d88f51cc4f5c";
 />
   <img width="1440" height="765" alt="after-earlyexit" 
src="https://github.com/user-attachments/assets/f7d988f0-c1f6-4c94-854f-43329f606ce2";
 />
   
   ### Any related issues, documentation, discussions?
   
   Closes #9361 
   
   ### How was this PR tested?
   
   Added 14 tests, written before the fix; all pass with it. 12 fail on main; 
the other 2 are guards that pass on both.
   
   - `PythonWorkflowWorkerSpec`, 9 tests with shell-script interpreters under a 
parent actor that records what the worker throws: exit mid-run (codes 3 and 0), 
SIGKILL, client stops, client stops after the process is gone, exit before 
connecting, and both exits again while a child of the interpreter keeps its 
output open. Guard: stopping the worker reports nothing. Its process stand-ins 
now extend `java.lang.Process`, the type the worker uses.
   - `PythonProxyClientSpec`, 4 tests: an ack that arrives after 6 s (main: 
NPE, the next put is never sent); a put that fails after its ack; a put that 
ends without one; guard: a rejected put still ends the client with the server's 
error.
   - `PythonWorkerFailureIntegrationSpec`, an `@IntegrationTest` that SIGKILLs 
a real Python worker mid-run: the run fails within seconds naming the worker 
and code 137 (main: times out).
   
   ```
   sbt "WorkflowExecutionService/testOnly 
org.apache.texera.amber.engine.architecture.pythonworker.PythonProxyClientSpec 
org.apache.texera.amber.engine.architecture.pythonworker.PythonWorkflowWorkerSpec"
   UDF_PYTHON_PATH=<python> sbt "WorkflowExecutionService/testOnly 
org.apache.texera.amber.engine.e2e.PythonWorkerFailureIntegrationSpec"
   ```
   
   The amber unit and integration suites give the same results as main apart 
from the new tests. In the UI, the three cases above behave as shown, killing a 
worker whose UDF started a helper subprocess fails the run within 0.1 s, and 
Kill and Pause → Resume during a Python run behave as on main.
   
   ### Was this PR authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Code (Claude Opus 5.5)


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