Apache Lucene open-source search software
SOLR-14402: Avoid creating new exceptions for every request made to MDCAwareThreadPoolExecutor by distributed search.
Shalin Shekhar Mangard52c1021e543
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex 9dda7dfa233..0a4ab8d6815 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -115,6 +115,10 @@ Bug Fixes* SOLR-14359: Admin UI collection/core drop-downs had wrong placeholder text. Fixed by upgrading angular-chosen (janhoy)+* SOLR-14402: Avoid creating new exceptions for every request made to MDCAwareThreadPoolExecutor by distributed search.+ This is a fix for incomplete optimization made by SOLR-11880 in Solr 7.4 which fixed distributed updates but not+ distributed search. (shalin)+Other Changes---------------------* SOLR-14197: SolrResourceLoader: marked many methods as deprecated, and in some cases rerouted exiting logic to avoiddiff --git a/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandlerFactory.java b/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandlerFactory.javaindex 3e7e39d6d90..0fd2687d852 100644--- a/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandlerFactory.java+++ b/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandlerFactory.java@@ -90,16 +90,9 @@ public class HttpShardHandlerFactory extends ShardHandlerFactory implements org.//// Consider CallerRuns policy and a lower max threads to throttle// requests at some point (or should we simply return failure?)- private ExecutorService commExecutor = new ExecutorUtil.MDCAwareThreadPoolExecutor(- 0,- Integer.MAX_VALUE,- 5, TimeUnit.SECONDS, // terminate idle threads after 5 sec- new SynchronousQueue<>(), // directly hand off tasks- new DefaultSolrThreadFactory("httpShardExecutor"),- // the Runnable added to this executor handles all exceptions so we disable stack trace collection as an optimization- // see SOLR-11880 for more details- false- );+ //+ // This executor is initialized in the init method+ private ExecutorService commExecutor;protected volatile Http2SolrClient defaultClient;protected InstrumentedHttpListenerFactory httpListenerFactory;@@ -306,7 +299,10 @@ public class HttpShardHandlerFactory extends ShardHandlerFactory implements org.this.maximumPoolSize,this.keepAliveTime, TimeUnit.SECONDS,blockingQueue,- new DefaultSolrThreadFactory("httpShardExecutor")+ new DefaultSolrThreadFactory("httpShardExecutor"),+ // the Runnable added to this executor handles all exceptions so we disable stack trace collection as an optimization+ // see SOLR-11880 for more details+ false);this.httpListenerFactory = new InstrumentedHttpListenerFactory(this.metricNameStrategy);diff --git a/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java b/solr/core/src/test/org/apache/solr/cloud/OverseerTest.javaindex 25e95cfb52c..148e68982eb 100644--- a/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/OverseerTest.java@@ -74,6 +74,7 @@ import org.apache.solr.common.util.TimeSource;import org.apache.solr.common.util.Utils;import org.apache.solr.core.CloudConfig;import org.apache.solr.core.CoreContainer;+import org.apache.solr.core.PluginInfo;import org.apache.solr.core.SolrResourceLoader;import org.apache.solr.handler.component.HttpShardHandler;import org.apache.solr.handler.component.HttpShardHandlerFactory;@@ -732,6 +733,7 @@ public class OverseerTest extends SolrTestCaseJ4 {UpdateShardHandler updateShardHandler = new UpdateShardHandler(UpdateShardHandlerConfig.DEFAULT);updateShardHandlers.add(updateShardHandler);HttpShardHandlerFactory httpShardHandlerFactory = new HttpShardHandlerFactory();+ httpShardHandlerFactory.init(new PluginInfo("shardHandlerFactory", Collections.emptyMap()));httpShardHandlerFactorys.add(httpShardHandlerFactory);Overseer overseer = new Overseer((HttpShardHandler) httpShardHandlerFactory.getShardHandler(), updateShardHandler, "/admin/cores", reader, zkController,new CloudConfig.CloudConfigBuilder("127.0.0.1", 8983, "").build());@@ -1398,6 +1400,7 @@ public class OverseerTest extends SolrTestCaseJ4 {UpdateShardHandler updateShardHandler = new UpdateShardHandler(UpdateShardHandlerConfig.DEFAULT);updateShardHandlers.add(updateShardHandler);HttpShardHandlerFactory httpShardHandlerFactory = new HttpShardHandlerFactory();+ httpShardHandlerFactory.init(new PluginInfo("shardHandlerFactory", Collections.emptyMap()));httpShardHandlerFactorys.add(httpShardHandlerFactory);ZkController zkController = createMockZkController(address, null, reader);diff --git a/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java b/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.javaindex 43a75408693..4526ed4d025 100644--- a/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java@@ -35,10 +35,7 @@ import org.apache.solr.common.cloud.ZkNodeProps;import org.apache.solr.common.cloud.ZkStateReader;import org.apache.solr.common.params.CollectionParams;import org.apache.solr.common.util.Utils;-import org.apache.solr.core.CloudConfig;-import org.apache.solr.core.CoreContainer;-import org.apache.solr.core.CoreDescriptor;-import org.apache.solr.core.SolrXmlConfig;+import org.apache.solr.core.*;import org.apache.solr.handler.admin.CoreAdminHandler;import org.apache.solr.handler.component.HttpShardHandlerFactory;import org.apache.solr.update.UpdateShardHandler;@@ -340,7 +337,9 @@ public class ZkControllerTest extends SolrTestCaseJ4 {public MockCoreContainer() {super(SolrXmlConfig.fromString(TEST_PATH(), "<solr/>"));- this.shardHandlerFactory = new HttpShardHandlerFactory();+ HttpShardHandlerFactory httpShardHandlerFactory = new HttpShardHandlerFactory();+ httpShardHandlerFactory.init(new PluginInfo("shardHandlerFactory", Collections.emptyMap()));+ this.shardHandlerFactory = httpShardHandlerFactory;this.coreAdminHandler = new CoreAdminHandler();}