Apache Lucene open-source search software
SOLR-12923: fix SimClusterStateProvider to use lock.lockInterruptibly() exclusively, and make SimCloudManager's Callable checks tollerant of Callables that may have failed related to interrupts w/o explicitly throwing InterruptedException
Chris Hostetter1a54c6b19db9
diff --git a/solr/core/src/test/org/apache/solr/cloud/autoscaling/sim/SimCloudManager.java b/solr/core/src/test/org/apache/solr/cloud/autoscaling/sim/SimCloudManager.javaindex fda1892c9e6..7ce45346018 100644--- a/solr/core/src/test/org/apache/solr/cloud/autoscaling/sim/SimCloudManager.java+++ b/solr/core/src/test/org/apache/solr/cloud/autoscaling/sim/SimCloudManager.java@@ -967,6 +967,21 @@ public class SimCloudManager implements SolrCloudManager {log.warn("Callable interupted", ignored);throw ignored;} catch (Throwable t) {+ // be forgiving of errors that occured as a result of interuption, even if+ // the inner Callable didn't realize it...+ if (Thread.currentThread().isInterrupted()) {+ log.warn("Callable interupted w/o noticing", t);+ throw t;+ }+ Throwable cause = t;+ while ((cause = cause.getCause()) != null) {+ if (cause instanceof InterruptedException) {+ log.warn("Callable threw wrapped InterruptedException", t);+ throw t;+ }+ }++ // in all other situations, this is a problem that should be tracked in the failCounterfailCounter.incrementAndGet();log.error("Callable failed", t);throw t;diff --git a/solr/core/src/test/org/apache/solr/cloud/autoscaling/sim/SimClusterStateProvider.java b/solr/core/src/test/org/apache/solr/cloud/autoscaling/sim/SimClusterStateProvider.javaindex 7e738b93283..3d6becee390 100644--- a/solr/core/src/test/org/apache/solr/cloud/autoscaling/sim/SimClusterStateProvider.java+++ b/solr/core/src/test/org/apache/solr/cloud/autoscaling/sim/SimClusterStateProvider.java@@ -18,6 +18,7 @@package org.apache.solr.cloud.autoscaling.sim;import java.io.IOException;+import java.lang.InterruptedException;import java.lang.invoke.MethodHandles;import java.util.ArrayList;import java.util.Arrays;@@ -190,7 +191,7 @@ public class SimClusterStateProvider implements ClusterStateProvider {* @param initialState initial cluster state*/public void simSetClusterState(ClusterState initialState) throws Exception {- lock.lock();+ lock.lockInterruptibly();try {collProperties.clear();sliceProperties.clear();@@ -2148,20 +2149,24 @@ public class SimClusterStateProvider implements ClusterStateProvider {@Overridepublic ClusterState getClusterState() throws IOException {ensureNotClosed();- lock.lock();try {- Map<String, DocCollection> states = getCollectionStates();- ClusterState state = new ClusterState(clusterStateVersion, liveNodes.get(), states);- return state;- } finally {- lock.unlock();+ lock.lockInterruptibly();+ try {+ Map<String, DocCollection> states = getCollectionStates();+ ClusterState state = new ClusterState(clusterStateVersion, liveNodes.get(), states);+ return state;+ } finally {+ lock.unlock();+ }+ } catch (InterruptedException e) {+ throw new IOException(e);}}// this method uses a simple cache in collectionsStatesRef. Operations that modify// cluster state should always reset this cache so that the changes become visible- private Map<String, DocCollection> getCollectionStates() throws IOException {- lock.lock();+ private Map<String, DocCollection> getCollectionStates() throws IOException, InterruptedException {+ lock.lockInterruptibly();try {Map<String, DocCollection> collectionStates = collectionsStatesRef.get();if (collectionStates != null) {