[ 
https://issues.apache.org/jira/browse/SPARK-58751?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jungtaek Lim resolved SPARK-58751.
----------------------------------
    Fix Version/s: 4.3.0
                   4.1.4
                   4.2.1
       Resolution: Fixed

Issue resolved by pull request 57941
[https://github.com/apache/spark/pull/57941]

> TransformWithState leaks Python workers when initialization fails
> -----------------------------------------------------------------
>
>                 Key: SPARK-58751
>                 URL: https://issues.apache.org/jira/browse/SPARK-58751
>             Project: Spark
>          Issue Type: Bug
>          Components: PySpark, Structured Streaming
>    Affects Versions: 4.0.0
>            Reporter: Jonathan Gao
>            Assignee: Jonathan Gao
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 4.1.4, 4.2.1, 4.3.0
>
>
> `TransformWithStateInPySpark` can create a Python worker during driver-side 
> initialization before initialization completes. If initialization fails after 
> worker creation, the previous lifecycle does not reach `stop()`, so the 
> worker and associated resources can remain alive for the driver lifetime.
> Repeated streaming restarts can accumulate leaked workers and eventually 
> prevent subsequent isolated workers from starting.
> The proposed fix moves the driver-side pre-initialization runner lifecycle 
> (`init`, `process`, and `stop`) into a cleanup-protected path so `stop()` 
> runs on initialization and processing failures. It also preserves the 
> original initialization failure when cleanup itself throws, and null-guards 
> the state-server daemon thread because that thread is assigned only near the 
> end of initialization.
> Regression coverage uses a stubbed pre-init runner, so no real Python worker 
> is required. The suite covers:
> * initialization failure after worker creation still stops the runner
> * repeated initialization failures do not accumulate live workers
> * cleanup failure is attached as suppressed rather than masking the 
> initialization error
> * process failure is still wrapped as a driver-worker crash and still stops 
> the runner
> * success path stops the runner exactly once
> * stopping before state-server startup does not throw a null-pointer exception
> Pull request: https://github.com/apache/spark/pull/57941



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to