Apache Solr open-source search software
SOLR-13350: multi-threaded search: replace cached with fixed threadpool (#2508)
Christine Poerschkedfdbf85a1da4
diff --git a/solr/core/src/java/org/apache/solr/core/CoreContainer.java b/solr/core/src/java/org/apache/solr/core/CoreContainer.javaindex f443e68d828..174deadd4fb 100644--- a/solr/core/src/java/org/apache/solr/core/CoreContainer.java+++ b/solr/core/src/java/org/apache/solr/core/CoreContainer.java@@ -445,7 +445,7 @@ public class CoreContainer {final int indexSearcherExecutorThreads = cfg.getIndexSearcherExecutorThreads();if (0 < indexSearcherExecutorThreads) {this.collectorExecutor =- ExecutorUtil.newMDCAwareCachedThreadPool(+ ExecutorUtil.newMDCAwareFixedThreadPool(indexSearcherExecutorThreads, // thread countindexSearcherExecutorThreads * 1000, // queue sizenew 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.javaindex 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.