Skip to content

Apache Lucene open-source search software

SOLR-5240: unlimited core loading threads to fix waiting-for-other-replicas deadlock

Yonik Seeley4b0c01af4178
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index e59d74c0431..da35fa2590d 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -267,6 +267,11 @@ Bug Fixes
* SOLR-5150: HdfsIndexInput may not fully read requested bytes. (Mark Miller, Patrick Hunt)
+* SOLR-5240: All solr cores will now be loaded in parallel (as opposed to a fixed number)
+ in zookeeper mode to avoid deadlocks due to replicas waiting for other replicas
+ to come up. (yonik)
+
+
Optimizations
----------------------
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 624b22c312d..c28a88470df 100644
--- a/solr/core/src/java/org/apache/solr/core/CoreContainer.java
+++ b/solr/core/src/java/org/apache/solr/core/CoreContainer.java
@@ -57,6 +57,9 @@ import java.util.concurrent.ExecutorCompletionService;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
import static com.google.common.base.Preconditions.checkNotNull;
@@ -209,8 +212,10 @@ public class CoreContainer {
containerProperties = cfg.getSolrProperties("solr");
// setup executor to load cores in parallel
- ExecutorService coreLoadExecutor = Executors.newFixedThreadPool(cfg.getCoreLoadThreadCount(),
- new DefaultSolrThreadFactory("coreLoadExecutor"));
+ // do not limit the size of the executor in zk mode since cores may try and wait for each other.
+ ExecutorService coreLoadExecutor = Executors.newFixedThreadPool(
+ ( zkSys.getZkController() == null ? cfg.getCoreLoadThreadCount() : Integer.MAX_VALUE ),
+ new DefaultSolrThreadFactory("coreLoadExecutor") );
try {
CompletionService<SolrCore> completionService = new ExecutorCompletionService<SolrCore>(