This is an automated email from the ASF dual-hosted git repository.
ishan pushed a commit to branch jira/solr-13350-fixes-9x
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/jira/solr-13350-fixes-9x by
this push:
new 699b8613eba SOLR-13350: Replacing cached pools with fixed pools
699b8613eba is described below
commit 699b8613ebaa3f8024e85fb6ee7dc4ef8b05c991
Author: Ishan Chattopadhyaya <[email protected]>
AuthorDate: Wed Jun 26 03:41:56 2024 +0530
SOLR-13350: Replacing cached pools with fixed pools
---
solr/core/src/java/org/apache/solr/core/CoreContainer.java | 2 +-
.../src/java/org/apache/solr/common/util/ExecutorUtil.java | 11 +++++++++++
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/solr/core/src/java/org/apache/solr/core/CoreContainer.java
b/solr/core/src/java/org/apache/solr/core/CoreContainer.java
index 7524135d92b..ed19d0fa0f1 100644
--- a/solr/core/src/java/org/apache/solr/core/CoreContainer.java
+++ b/solr/core/src/java/org/apache/solr/core/CoreContainer.java
@@ -448,7 +448,7 @@ public class CoreContainer {
this.allowListUrlChecker = AllowListUrlChecker.create(config);
this.collectorExecutor =
- ExecutorUtil.newMDCAwareCachedThreadPool(
+ ExecutorUtil.newMDCAwareFixedThreadPool(
cfg.getIndexSearcherExecutorThreads(), // thread count
cfg.getIndexSearcherExecutorThreads() * 1000, // queue size
new SolrNamedThreadFactory("searcherCollector"));
diff --git a/solr/solrj/src/java/org/apache/solr/common/util/ExecutorUtil.java
b/solr/solrj/src/java/org/apache/solr/common/util/ExecutorUtil.java
index 0fb3f8f4153..a0444ea5a53 100644
--- a/solr/solrj/src/java/org/apache/solr/common/util/ExecutorUtil.java
+++ b/solr/solrj/src/java/org/apache/solr/common/util/ExecutorUtil.java
@@ -201,6 +201,17 @@ public class ExecutorUtil {
nThreads, nThreads, 0L, TimeUnit.MILLISECONDS, new
LinkedBlockingQueue<>(), threadFactory);
}
+ public static ExecutorService newMDCAwareFixedThreadPool(
+ int nThreads, int queueCapacity, ThreadFactory threadFactory) {
+ return new MDCAwareThreadPoolExecutor(
+ nThreads,
+ nThreads,
+ 0L,
+ TimeUnit.MILLISECONDS,
+ new LinkedBlockingQueue<>(queueCapacity),
+ threadFactory);
+ }
+
/**
* See {@link
java.util.concurrent.Executors#newSingleThreadExecutor(ThreadFactory)}. Note the
* thread is always active, even if no tasks are submitted to the executor.