This is an automated email from the ASF dual-hosted git repository.

ishan pushed a commit to branch jira/solr-13350
in repository https://gitbox.apache.org/repos/asf/solr.git


The following commit(s) were added to refs/heads/jira/solr-13350 by this push:
     new 1dc4314e160 SOLR-13350: Using a RejectedExecutionHandler that submits 
the tasks back in for retry
1dc4314e160 is described below

commit 1dc4314e1602e533f4c8650a9522f10e7f70f6e2
Author: Ishan Chattopadhyaya <[email protected]>
AuthorDate: Wed Apr 3 03:26:04 2024 +0530

    SOLR-13350: Using a RejectedExecutionHandler that submits the tasks back in 
for retry
---
 solr/core/src/java/org/apache/solr/core/CoreContainer.java | 13 +++++++++++++
 1 file changed, 13 insertions(+)

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 2925095b2d5..706935ecc14 100644
--- a/solr/core/src/java/org/apache/solr/core/CoreContainer.java
+++ b/solr/core/src/java/org/apache/solr/core/CoreContainer.java
@@ -52,6 +52,8 @@ import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.Executor;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.TimeoutException;
+import java.util.concurrent.RejectedExecutionHandler;
+import java.util.concurrent.ThreadPoolExecutor;
 import java.util.function.Function;
 import java.util.function.Supplier;
 import java.util.stream.Collectors;
@@ -445,6 +447,17 @@ public class CoreContainer {
             cfg.getIndexSearcherExecutorThreads(), // thread count
             cfg.getIndexSearcherExecutorThreads(), // queue size
             new SolrNamedThreadFactory("searcherCollector"));
+    ((ExecutorUtil.MDCAwareThreadPoolExecutor) 
collectorExecutor).setRejectedExecutionHandler(new RejectedExecutionHandler() {
+      @Override
+      public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
+        if (!executor.isShutdown()) {
+          try {
+            executor.getQueue().put(r);
+          } catch (InterruptedException e) {
+          }
+        }
+      }
+    });
   }
 
   @SuppressWarnings({"unchecked"})

Reply via email to