You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@curator.apache.org by "QiuYucheng2003 (via GitHub)" <gi...@apache.org> on 2026/01/13 02:21:56 UTC
[I] [Bug] Potential OOM in ThreadUtils due to unbounded newFixedThreadPool [curator]
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: commits-unsubscribe@curator.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Bug] Potential OOM in ThreadUtils due to unbounded newFixedThreadPool [curator]
Posted by "tisonkun (via GitHub)" <gi...@apache.org>.
tisonkun commented on issue #1283:
URL: https://github.com/apache/curator/issues/1283#issuecomment-4071292400
@QiuYucheng2003 Thanks for reporting this issue and I can see that you provide a possible fix.
Would you like to submit a PR so that we can review the patch easiler?
--
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: commits-unsubscribe@curator.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org