|
34 | 34 | import java.util.Set; |
35 | 35 | import java.util.concurrent.ConcurrentHashMap; |
36 | 36 | import java.util.concurrent.ExecutorService; |
37 | | -import java.util.concurrent.SynchronousQueue; |
| 37 | +import java.util.concurrent.LinkedBlockingQueue; |
38 | 38 | import java.util.concurrent.TimeUnit; |
39 | 39 | import java.util.concurrent.atomic.AtomicLong; |
40 | 40 | import java.util.concurrent.atomic.AtomicReference; |
|
96 | 96 | import org.apache.solr.common.SolrException.ErrorCode; |
97 | 97 | import org.apache.solr.common.params.ModifiableSolrParams; |
98 | 98 | import org.apache.solr.common.util.CollectionUtil; |
| 99 | +import org.apache.solr.common.util.EnvUtils; |
99 | 100 | import org.apache.solr.common.util.ExecutorUtil.MDCAwareThreadPoolExecutor; |
100 | 101 | import org.apache.solr.common.util.ObjectReleaseTracker; |
101 | 102 | import org.apache.solr.common.util.SolrNamedThreadFactory; |
@@ -228,25 +229,15 @@ public static ExecutorService initCollectorExecutor(NodeConfig cfg) { |
228 | 229 | return null; |
229 | 230 | } |
230 | 231 |
|
| 232 | + // note that Lucene will catch a RejectedExecutionException to just run the task. |
| 233 | + // Therefore, we shouldn't worry too much about the queue size. |
231 | 234 | return new MDCAwareThreadPoolExecutor( |
232 | 235 | indexSearcherExecutorThreads, |
233 | 236 | indexSearcherExecutorThreads, |
234 | 237 | 0L, |
235 | 238 | TimeUnit.MILLISECONDS, |
236 | | - new SynchronousQueue<>(true) { // fairness |
237 | | - // a hack to force ThreadPoolExecutor to block if threads are busy |
238 | | - // -- otherwise it will throw RejectedExecutionException; unacceptable |
239 | | - @Override |
240 | | - public boolean offer(Runnable runnable) { // is supposed to not block, but we do anyway |
241 | | - try { |
242 | | - put(runnable); // blocks |
243 | | - } catch (InterruptedException e) { |
244 | | - Thread.currentThread().interrupt(); |
245 | | - throw new RuntimeException("interrupted submitting to search multi-threaded pool", e); |
246 | | - } |
247 | | - return true; |
248 | | - } |
249 | | - }, |
| 239 | + new LinkedBlockingQueue<>( |
| 240 | + EnvUtils.getPropertyAsInteger("solr.search.multiThreaded.queueSize", 1000)), |
250 | 241 | new SolrNamedThreadFactory("searcherCollector")) { |
251 | 242 |
|
252 | 243 | @Override |
|
0 commit comments