dsmiley commented on code in PR #2276:
URL: https://github.com/apache/solr/pull/2276#discussion_r1495075326


##########
solr/core/src/test/org/apache/solr/cloud/RecoveryStrategyStressTest.java:
##########
@@ -0,0 +1,135 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.solr.cloud;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+import org.apache.solr.client.solrj.SolrClient;
+import org.apache.solr.client.solrj.SolrQuery;
+import org.apache.solr.client.solrj.SolrServerException;
+import org.apache.solr.client.solrj.impl.CloudLegacySolrClient;
+import org.apache.solr.client.solrj.impl.HttpSolrClient;
+import org.apache.solr.client.solrj.request.CollectionAdminRequest;
+import org.apache.solr.client.solrj.request.UpdateRequest;
+import org.apache.solr.common.cloud.DocCollection;
+import org.apache.solr.common.cloud.Replica;
+import org.apache.solr.common.cloud.Slice;
+import org.apache.solr.common.util.SolrNamedThreadFactory;
+import org.apache.solr.embedded.JettySolrRunner;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class RecoveryStrategyStressTest extends SolrCloudTestCase {
+
+  @BeforeClass
+  public static void setupCluster() throws Exception {
+    cluster = configureCluster(4).addConfig("conf", 
configset("cloud-minimal")).configure();
+  }
+
+  @Test
+  public void stressTestRecovery() throws Exception {
+    final String collection = "recoveryStressTest";
+    CollectionAdminRequest.createCollection(collection, "conf", 1, 4)
+        .process(cluster.getSolrClient());
+    waitForState(
+        "Expected a collection with one shard and two replicas", collection, 
clusterShape(1, 4));
+
+    SolrClient solrClient =

Review Comment:
   why not declare this in the `try`?



##########
solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java:
##########
@@ -911,18 +911,39 @@ private final void sendPrepRecoveryCmd(String 
leaderBaseUrl, String leaderCoreNa
     int readTimeout =
         conflictWaitMs
             + 
Integer.parseInt(System.getProperty("prepRecoveryReadTimeoutExtraWait", 
"8000"));
-    try (HttpSolrClient client =
+    var recoveryExec =
+        ExecutorUtil.newMDCAwareFixedThreadPool(
+            1, new SolrNamedThreadFactory("sendPrepRecoveryCmd"));
+    try (Http2SolrClient client =
         recoverySolrClientBuilder(
                 leaderBaseUrl,
                 null) // leader core omitted since client only used for 
'admin' request
-            .withSocketTimeout(readTimeout, TimeUnit.MILLISECONDS)
+            .withIdleTimeout(readTimeout, TimeUnit.MILLISECONDS)
+            .withExecutor(recoveryExec)
             .build()) {
-      HttpUriRequestResponse mrr = client.httpUriRequest(prepCmd);
-      prevSendPreRecoveryHttpUriRequest = mrr.httpUriRequest;
-
       log.info("Sending prep recovery command to [{}]; [{}]", leaderBaseUrl, 
prepCmd);
-
-      mrr.future.get();
+      MDC.put("HttpSolrClient.url", baseUrl);
+      prevSendPreRecoveryHttpUriRequest =
+          client.asyncRequest(
+              prepCmd,
+              null,
+              new AsyncListener<>() {
+                @Override
+                public void onSuccess(NamedList<Object> entries) {
+                  log.info(
+                      "Prep recovery command successfully send to [{}]; [{}]",

Review Comment:
   send -> sent



##########
solr/core/src/test/org/apache/solr/cloud/RecoveryStrategyStressTest.java:
##########
@@ -0,0 +1,135 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.solr.cloud;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+import org.apache.solr.client.solrj.SolrClient;
+import org.apache.solr.client.solrj.SolrQuery;
+import org.apache.solr.client.solrj.SolrServerException;
+import org.apache.solr.client.solrj.impl.CloudLegacySolrClient;
+import org.apache.solr.client.solrj.impl.HttpSolrClient;
+import org.apache.solr.client.solrj.request.CollectionAdminRequest;
+import org.apache.solr.client.solrj.request.UpdateRequest;
+import org.apache.solr.common.cloud.DocCollection;
+import org.apache.solr.common.cloud.Replica;
+import org.apache.solr.common.cloud.Slice;
+import org.apache.solr.common.util.SolrNamedThreadFactory;
+import org.apache.solr.embedded.JettySolrRunner;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class RecoveryStrategyStressTest extends SolrCloudTestCase {

Review Comment:
   Lets tag this with `@Nightly`



##########
solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java:
##########
@@ -911,18 +911,39 @@ private final void sendPrepRecoveryCmd(String 
leaderBaseUrl, String leaderCoreNa
     int readTimeout =
         conflictWaitMs
             + 
Integer.parseInt(System.getProperty("prepRecoveryReadTimeoutExtraWait", 
"8000"));
-    try (HttpSolrClient client =
+    var recoveryExec =
+        ExecutorUtil.newMDCAwareFixedThreadPool(
+            1, new SolrNamedThreadFactory("sendPrepRecoveryCmd"));

Review Comment:
   Come to think of it, maybe the executor should be the field so is re-used?



##########
solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java:
##########
@@ -176,23 +179,21 @@ public final void setRecoveringAfterStartup(boolean 
recoveringAfterStartup) {
   }
 
   /** Builds a new HttpSolrClient for use in recovery. Caller must close */

Review Comment:
   I'd eliminate this javadoc; it doesn't add anything beyond the signature.  
"Caller must close" is obsolete by earlier changes; a Builder isn't closeable.



##########
solr/core/src/java/org/apache/solr/update/UpdateShardHandler.java:
##########
@@ -75,7 +75,8 @@ public class UpdateShardHandler implements SolrInfoBean {
 
   private final Http2SolrClient updateOnlyClient;
 
-  private final CloseableHttpClient recoveryOnlyClient;
+  // private final CloseableHttpClient recoveryOnlyClient;

Review Comment:
   remove the comment



##########
solr/core/src/java/org/apache/solr/update/UpdateShardHandler.java:
##########
@@ -133,16 +135,25 @@ public UpdateShardHandler(UpdateShardHandlerConfig cfg) {
             DistributedUpdateProcessor.DISTRIB_FROM,
             DistributingUpdateProcessorFactory.DISTRIB_UPDATE_PARAM);
     Http2SolrClient.Builder updateOnlyClientBuilder = new 
Http2SolrClient.Builder();
+    Http2SolrClient.Builder recoveryOnlyClientBuilder = new 
Http2SolrClient.Builder();

Review Comment:
   Come to think of it, updateOnly & recoveryOnly clients are configured the 
same except for `withTheseParamNamesInTheUrl` but it's benign to have that 
shared.  Ultimately, the point I think is for both clients to be separated so 
that saturation in one (particularly updates) doesn't block the other 
(recovery).  Hopefully I can get Mark Miller to weigh in.



##########
solr/core/src/java/org/apache/solr/update/UpdateShardHandler.java:
##########
@@ -121,9 +124,8 @@ public UpdateShardHandler(UpdateShardHandlerConfig cfg) {
 
     httpRequestExecutor = new 
InstrumentedHttpRequestExecutor(getMetricNameStrategy(cfg));
     updateHttpListenerFactory = new 
InstrumentedHttpListenerFactory(getNameStrategy(cfg));
-    recoveryOnlyClient =
-        HttpClientUtil.createClient(
-            clientParams, recoveryOnlyConnectionManager, false, 
httpRequestExecutor);
+    recoverHttpListenerFactory = new 
InstrumentedHttpListenerFactory(getNameStrategy(cfg));
+

Review Comment:
   Do we really need a second InstrumentedHttpListenerFactory?  They look 
identical.



##########
solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java:
##########
@@ -911,18 +911,39 @@ private final void sendPrepRecoveryCmd(String 
leaderBaseUrl, String leaderCoreNa
     int readTimeout =
         conflictWaitMs
             + 
Integer.parseInt(System.getProperty("prepRecoveryReadTimeoutExtraWait", 
"8000"));
-    try (HttpSolrClient client =
+    var recoveryExec =
+        ExecutorUtil.newMDCAwareFixedThreadPool(
+            1, new SolrNamedThreadFactory("sendPrepRecoveryCmd"));
+    try (Http2SolrClient client =
         recoverySolrClientBuilder(
                 leaderBaseUrl,
                 null) // leader core omitted since client only used for 
'admin' request
-            .withSocketTimeout(readTimeout, TimeUnit.MILLISECONDS)
+            .withIdleTimeout(readTimeout, TimeUnit.MILLISECONDS)
+            .withExecutor(recoveryExec)
             .build()) {
-      HttpUriRequestResponse mrr = client.httpUriRequest(prepCmd);
-      prevSendPreRecoveryHttpUriRequest = mrr.httpUriRequest;
-
       log.info("Sending prep recovery command to [{}]; [{}]", leaderBaseUrl, 
prepCmd);
-
-      mrr.future.get();
+      MDC.put("HttpSolrClient.url", baseUrl);

Review Comment:
   Why this MDC url; are you imitating something you saw elsewhere?



##########
solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java:
##########
@@ -911,18 +911,39 @@ private final void sendPrepRecoveryCmd(String 
leaderBaseUrl, String leaderCoreNa
     int readTimeout =
         conflictWaitMs
             + 
Integer.parseInt(System.getProperty("prepRecoveryReadTimeoutExtraWait", 
"8000"));
-    try (HttpSolrClient client =
+    var recoveryExec =
+        ExecutorUtil.newMDCAwareFixedThreadPool(
+            1, new SolrNamedThreadFactory("sendPrepRecoveryCmd"));

Review Comment:
   Maybe use newMDCAwareSingleThreadExecutor ?  Also define the threadFactory 
as a field so that the thread names it generates will change over time 
(increments a counter)



##########
solr/core/src/java/org/apache/solr/update/UpdateShardHandler.java:
##########
@@ -121,9 +124,8 @@ public UpdateShardHandler(UpdateShardHandlerConfig cfg) {
 
     httpRequestExecutor = new 
InstrumentedHttpRequestExecutor(getMetricNameStrategy(cfg));
     updateHttpListenerFactory = new 
InstrumentedHttpListenerFactory(getNameStrategy(cfg));
-    recoveryOnlyClient =
-        HttpClientUtil.createClient(
-            clientParams, recoveryOnlyConnectionManager, false, 
httpRequestExecutor);
+    recoverHttpListenerFactory = new 
InstrumentedHttpListenerFactory(getNameStrategy(cfg));
+

Review Comment:
   You could rename updateHttpListenerFactory "http2Instrumenter" or something 
as it may slightly better convey it's purpose.



##########
solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java:
##########
@@ -911,18 +911,39 @@ private final void sendPrepRecoveryCmd(String 
leaderBaseUrl, String leaderCoreNa
     int readTimeout =
         conflictWaitMs
             + 
Integer.parseInt(System.getProperty("prepRecoveryReadTimeoutExtraWait", 
"8000"));
-    try (HttpSolrClient client =
+    var recoveryExec =
+        ExecutorUtil.newMDCAwareFixedThreadPool(
+            1, new SolrNamedThreadFactory("sendPrepRecoveryCmd"));

Review Comment:
   shutdown waits for completion; this may not be obvious but it's pertinent to 
the logic.  A comment should shine a light on this



##########
solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java:
##########
@@ -203,6 +203,9 @@ protected Http2SolrClient(String serverBaseUrl, Builder 
builder) {
     } else {
       this.urlParamNames = Set.of();
     }
+    if (builder.executor != null) {

Review Comment:
   *Move* code that is already initializing this in createHttpClient to here.  
It includes the boolean to close it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org
For additional commands, e-mail: issues-h...@solr.apache.org

Reply via email to