QiuYucheng2003 opened a new issue, #1283:
URL: https://github.com/apache/curator/issues/1283

   Problem Description 
   The org.apache.curator.utils.ThreadUtils.newFixedThreadPool method 
internally wraps Executors.newFixedThreadPool:
   // ThreadUtils.java
   public static ExecutorService newFixedThreadPool(int qty, String 
processName) {
       return Executors.newFixedThreadPool(qty, newThreadFactory(processName));
   }
   
   Root Cause 
   The JDK's Executors.newFixedThreadPool uses a LinkedBlockingQueue with a 
default capacity of Integer.MAX_VALUE. This creates an unbounded queue.
   
   Impact 
   In distributed scenarios (e.g., high ZooKeeper server latency or connection 
storms), background tasks and callbacks generated by Curator clients will 
accumulate indefinitely in this queue. Since there is no backpressure mechanism 
(queue capacity limit), this eventually leads to java.lang.OutOfMemoryError: 
Java heap space.
   
   Suggested Fix 
   Replace the Executors factory method with a direct ThreadPoolExecutor 
construction using a bounded queue (e.g., ArrayBlockingQueue) and an 
appropriate RejectedExecutionHandler.
   
   // Proposed change
   public static ExecutorService newFixedThreadPool(int qty, String 
processName) {
       return new ThreadPoolExecutor(
           qty, qty,
           0L, TimeUnit.MILLISECONDS,
           new LinkedBlockingQueue<>(10000), // Bounded capacity
           newThreadFactory(processName)
       );
   }


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