Skip to content

Apache Lucene open-source search software

SOLR-12801: Harden TestCloudRecovery.

markrmillerab891fa4728e
diff --git a/solr/core/src/java/org/apache/solr/update/UpdateLog.java b/solr/core/src/java/org/apache/solr/update/UpdateLog.java
index 0941da57b8d..612bc6e503d 100644
--- a/solr/core/src/java/org/apache/solr/update/UpdateLog.java
+++ b/solr/core/src/java/org/apache/solr/update/UpdateLog.java
@@ -1539,7 +1539,7 @@ public class UpdateLog implements PluginInfoInitialized, SolrMetricProducer {
numUpdates++;
}
- } catch (IOException e) {
+ } catch (IOException | AssertionError e) { // catch AssertionError to handle certain test failures correctly
// failure to read a log record isn't fatal
log.error("Exception reading versions from log",e);
} finally {
diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/ChaosMonkey.java b/solr/test-framework/src/java/org/apache/solr/cloud/ChaosMonkey.java
index e2bb5db642d..3b883e0d18f 100644
--- a/solr/test-framework/src/java/org/apache/solr/cloud/ChaosMonkey.java
+++ b/solr/test-framework/src/java/org/apache/solr/cloud/ChaosMonkey.java
@@ -17,13 +17,14 @@
package org.apache.solr.cloud;
import java.lang.invoke.MethodHandles;
-
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Random;
import java.util.Set;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.regex.Pattern;
@@ -38,10 +39,12 @@ import org.apache.solr.common.cloud.Slice;
import org.apache.solr.common.cloud.SolrZkClient;
import org.apache.solr.common.cloud.ZkNodeProps;
import org.apache.solr.common.cloud.ZkStateReader;
+import org.apache.solr.common.util.ExecutorUtil;
import org.apache.solr.common.util.TimeSource;
import org.apache.solr.core.CoreContainer;
import org.apache.solr.core.SolrCore;
import org.apache.solr.update.DirectUpdateHandler2;
+import org.apache.solr.util.DefaultSolrThreadFactory;
import org.apache.solr.util.RTimer;
import org.apache.solr.util.TimeOut;
import org.apache.zookeeper.KeeperException;
@@ -585,15 +588,45 @@ public class ChaosMonkey {
}
public static void stop(List<JettySolrRunner> jettys) throws Exception {
+ ExecutorService executor = new ExecutorUtil.MDCAwareThreadPoolExecutor(
+ 0,
+ Integer.MAX_VALUE,
+ 15, TimeUnit.SECONDS,
+ new SynchronousQueue<>(),
+ new DefaultSolrThreadFactory("ChaosMonkey"),
+ false);
for (JettySolrRunner jetty : jettys) {
- jetty.stop();
+ executor.submit(() -> {
+ try {
+ jetty.stop();
+ } catch (Exception e) {
+ log.error("error stopping jetty", e);
+ throw new RuntimeException(e);
+ }
+ });
}
+ ExecutorUtil.shutdownAndAwaitTermination(executor);
}
-
+
public static void start(List<JettySolrRunner> jettys) throws Exception {
+ ExecutorService executor = new ExecutorUtil.MDCAwareThreadPoolExecutor(
+ 0,
+ Integer.MAX_VALUE,
+ 15, TimeUnit.SECONDS,
+ new SynchronousQueue<>(),
+ new DefaultSolrThreadFactory("ChaosMonkey"),
+ false);
for (JettySolrRunner jetty : jettys) {
- jetty.start();
+ executor.submit(() -> {
+ try {
+ jetty.start();
+ } catch (Exception e) {
+ log.error("error starting jetty", e);
+ throw new RuntimeException(e);
+ }
+ });
}
+ ExecutorUtil.shutdownAndAwaitTermination(executor);
}
/**