wForget opened a new pull request, #2781:
URL: https://github.com/apache/uniffle/pull/2781

   ### What changes were proposed in this pull request?
   
   This PR fixes the prefetch executor thread leak in client read handlers.
   
   The following changes are included:
   
   - Invoke `super.close()` in `HadoopShuffleReadHandler.close()` to shut down 
the executor owned by `PrefetchableClientReadHandler`.
   - Implement `MultiReplicaClientReadHandler.close()` to close all underlying 
replica read handlers.
   - Initialize `prefetchExecutors` with a named daemon thread factory:
   
     ```java
     ThreadUtils.getThreadFactory("PrefetchableClientReadHandler")
     ```
   
     The generated thread names follow the `PrefetchableClientReadHandler-%d` 
format.
   
   ### Why are the changes needed?
   
   When prefetch is enabled, each `PrefetchableClientReadHandler` creates a 
dedicated executor.
   
   `HadoopShuffleReadHandler` overrides `close()` without invoking the parent 
implementation. In addition, `MultiReplicaClientReadHandler` does not propagate 
`close()` to its underlying handlers. Consequently, the prefetch executors may 
remain active after shuffle reading finishes.
   
   Under sustained workloads, the leaked threads can exhaust the process's 
native-thread resources and cause the following error:
   
   ```text
   java.lang.OutOfMemoryError: unable to create native thread: possibly out of 
memory or process/resource limits reached
       at java.base/java.lang.Thread.start0(Native Method)
       at java.base/java.lang.Thread.start(Thread.java:809)
       at 
java.base/java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:945)
       at 
java.base/java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1353)
       at 
java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:123)
       at 
org.apache.uniffle.storage.handler.impl.PrefetchableClientReadHandler.readShuffleData(PrefetchableClientReadHandler.java:96)
       at 
org.apache.uniffle.storage.handler.impl.HadoopClientReadHandler.readShuffleData(HadoopClientReadHandler.java:228)
       at 
org.apache.uniffle.storage.handler.impl.ComposedClientReadHandler.readShuffleData(ComposedClientReadHandler.java:122)
       at 
org.apache.uniffle.storage.handler.impl.MultiReplicaClientReadHandler.readShuffleData(MultiReplicaClientReadHandler.java:66)
   ```
   
   Closing the complete handler hierarchy ensures that the executors are shut 
down correctly. Using named daemon threads also improves thread identification 
and prevents prefetch threads from keeping the JVM alive.
   
   ### Does this PR introduce any user-facing changes?
   
   No.
   
   ### How was this patch tested?
   
   


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


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

Reply via email to