Matthew-DWM opened a new issue, #9361:
URL: https://github.com/apache/texera/issues/9361
### What happened?
When the Python process behind a Python UDF worker exits, or stays busy for
more than 5 seconds, the engine (JVM) side never finds out. The execution stays
`RUNNING` (or on "Submitting") with no error until the user kills it. Nothing
in this path times out; runs were watched hanging for up to 100 s.
```
Before: Python process exits / busy > 5 s -> JVM worker keeps waiting ->
run hangs, no error
After: Python process exits -> worker fails ->
run FAILED, naming the worker and exit code
Python process busy > 5 s -> worker keeps waiting ->
run completes
```
| Case | On main | Why |
| --- | --- | --- |
| The process is killed mid-run (e.g. by the out-of-memory killer) | stays
`RUNNING`, counts frozen (4 of 4 runs) | Nothing watches the process after
[`startPythonProcess`](https://github.com/apache/texera/blob/bb6136d8d5f0434b07337f995d3b15697c6ec862/amber/src/main/scala/org/apache/texera/amber/engine/architecture/pythonworker/PythonWorkflowWorker.scala#L248-L273)
starts it. The next Flight call fails on the client thread, and that error is
lost (next row). |
| Python is alive but doesn't acknowledge a data batch within 5 s (e.g. a
UDF holds the GIL in one long C call) | stays `RUNNING` with both Python
processes alive (2 of 3 runs; 2 of 2 with the statistics timer off) | Each ack
is awaited with [`poll(5,
SECONDS)`](https://github.com/apache/texera/blob/bb6136d8d5f0434b07337f995d3b15697c6ec862/amber/src/main/scala/org/apache/texera/amber/engine/architecture/pythonworker/PythonProxyClient.scala#L233),
which returns `null` on a timeout. The resulting `NullPointerException` ends
the client thread, whose `Future`
[`startProxyClient`](https://github.com/apache/texera/blob/bb6136d8d5f0434b07337f995d3b15697c6ec862/amber/src/main/scala/org/apache/texera/amber/engine/architecture/pythonworker/PythonWorkflowWorker.scala#L231-L233)
discards. |
| The process starts, then exits before reporting its port (e.g. an invalid
setting or a missing package) | Run button stays on "Submitting"; stopping the
computing unit times out | The worker actor waits for the port in `preStart`
with [`Await.result` and no
timeout](https://github.com/apache/texera/blob/bb6136d8d5f0434b07337f995d3b15697c6ec862/amber/src/main/scala/org/apache/texera/amber/engine/architecture/pythonworker/PythonProxyClient.scala#L60-L64).
|
**Expected:** the execution fails within seconds and names the worker and
exit code. A worker that is stopped on purpose (Kill, end of a region) or only
busy is not reported as failed.
The three cases need one fix: reporting the client thread's error without
fixing the 5 s wait would turn busy workers into false failures.
Related: #2030 added the port wait; #8667 has the same symptom from a
different path.
### How to reproduce?
Build CSV File Scan (20,000 rows `id,name,tag`, `tag` alternating
`alpha`/`beta`) → Python UDF → Keyword Search (`tag` = `alpha`), with this UDF:
```python
from pytexera import *
import time
class ProcessTupleOperator(UDFOperatorV2):
@overrides
def process_tuple(self, tuple_: Tuple, port: int) ->
Iterator[Optional[TupleLike]]:
time.sleep(0.001)
yield tuple_
```
Left alone, it completes with 10,000 rows. Then:
1. **Killed:** while it runs, `kill -9` the UDF's process on the computing
unit's host (`pgrep -f texera_run_python_worker`). The run stays `RUNNING`.
2. **Busy for over 5 s:** add a second Python UDF before Keyword Search that
holds the GIL for ~6.5 s every 4,000 rows (check that it's over 5 s on your
machine). The run stays `RUNNING` with both Python processes alive. It's a
race; starting the computing unit with `CONSTANTS_STATUS_UPDATE_INTERVAL=600000
CONSTANTS_RUNTIME_STATISTICS_PERSISTENCE_INTERVAL=600000` makes it much more
likely.
```python
from pytexera import *
class ProcessTupleOperator(UDFOperatorV2):
def __init__(self):
self.count = 0
@overrides
def process_tuple(self, tuple_: Tuple, port: int) ->
Iterator[Optional[TupleLike]]:
self.count += 1
if self.count % 4000 == 200:
sum(range(550_000_000)) # one C call that holds the GIL
yield tuple_
```
3. **Exits before connecting:** start the computing unit with
`UDF_PYTHON_LOG_STREAMHANDLER_LEVEL=NOT_A_LEVEL` and run the workflow. Python
exits with `ValueError: Level 'NOT_A_LEVEL' does not exist`, and the Run button
stays on "Submitting".
### Version/Branch
1.4.0-incubating-SNAPSHOT (main)
### Commit Hash (Optional)
bb6136d8d5f0434b07337f995d3b15697c6ec862
### What browsers are you seeing the problem on?
_No response_
### Relevant log output
```shell
Killed: nothing is logged after the kill.
Busy for over 5 s: the downstream worker's Flight client thread, sampled
once a second
t=4.0s SyncPutListener.poll < PythonProxyClient.writeArrowStream:233 <
sendData < mainLoop
t=9.1s (thread gone, nothing logged)
Exits before connecting: the worker actor, parked until the computing unit
is stopped
at com.twitter.util.Await$.result(Awaitable.scala:144)
at ...PythonProxyClient.<init>(PythonProxyClient.scala:60)
at ...PythonWorkflowWorker.startProxyClient(PythonWorkflowWorker.scala:232)
at ...WorkflowActor.preStart(WorkflowActor.scala:232)
Coordinated shutdown phase [actor-system-terminate] timed out after 10000
milliseconds
```
--
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]