You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by dw...@apache.org on 2021/03/10 10:07:11 UTC
[lucene] 09/18: 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
This is an automated email from the ASF dual-hosted git repository.
dweiss pushed a commit to branch branch_8_0
in repository https://gitbox.apache.org/repos/asf/lucene.git
commit 4552eeddc613a5e143c97963b504102c6f41af46
Author: Chris Hostetter <ho...@apache.org>
AuthorDate: Fri Mar 15 12:06:53 2019 -0700
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
(cherry picked from commit 1a54c6b19db9dcb1081e43614bf479e0ac7bf177)
---
.../cloud/autoscaling/sim/SimCloudManager.java | 15 ++++++++++++++
.../autoscaling/sim/SimClusterStateProvider.java | 23 +++++++++++++---------
2 files changed, 29 insertions(+), 9 deletions(-)
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.java
index fda1892..7ce4534 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 failCounter
failCounter.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.java
index 7e738b9..3d6bece 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 {
@Override
public 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) {