mirror of https://github.com/apache/lucene.git
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 commit is contained in:
parent
c79aeee5f9
commit
1a54c6b19d
|
@ -967,6 +967,21 @@ public class SimCloudManager implements SolrCloudManager {
|
||||||
log.warn("Callable interupted", ignored);
|
log.warn("Callable interupted", ignored);
|
||||||
throw ignored;
|
throw ignored;
|
||||||
} catch (Throwable t) {
|
} 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();
|
failCounter.incrementAndGet();
|
||||||
log.error("Callable failed", t);
|
log.error("Callable failed", t);
|
||||||
throw t;
|
throw t;
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
package org.apache.solr.cloud.autoscaling.sim;
|
package org.apache.solr.cloud.autoscaling.sim;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.lang.InterruptedException;
|
||||||
import java.lang.invoke.MethodHandles;
|
import java.lang.invoke.MethodHandles;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -190,7 +191,7 @@ public class SimClusterStateProvider implements ClusterStateProvider {
|
||||||
* @param initialState initial cluster state
|
* @param initialState initial cluster state
|
||||||
*/
|
*/
|
||||||
public void simSetClusterState(ClusterState initialState) throws Exception {
|
public void simSetClusterState(ClusterState initialState) throws Exception {
|
||||||
lock.lock();
|
lock.lockInterruptibly();
|
||||||
try {
|
try {
|
||||||
collProperties.clear();
|
collProperties.clear();
|
||||||
sliceProperties.clear();
|
sliceProperties.clear();
|
||||||
|
@ -2148,20 +2149,24 @@ public class SimClusterStateProvider implements ClusterStateProvider {
|
||||||
@Override
|
@Override
|
||||||
public ClusterState getClusterState() throws IOException {
|
public ClusterState getClusterState() throws IOException {
|
||||||
ensureNotClosed();
|
ensureNotClosed();
|
||||||
lock.lock();
|
|
||||||
try {
|
try {
|
||||||
Map<String, DocCollection> states = getCollectionStates();
|
lock.lockInterruptibly();
|
||||||
ClusterState state = new ClusterState(clusterStateVersion, liveNodes.get(), states);
|
try {
|
||||||
return state;
|
Map<String, DocCollection> states = getCollectionStates();
|
||||||
} finally {
|
ClusterState state = new ClusterState(clusterStateVersion, liveNodes.get(), states);
|
||||||
lock.unlock();
|
return state;
|
||||||
|
} finally {
|
||||||
|
lock.unlock();
|
||||||
|
}
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
throw new IOException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// this method uses a simple cache in collectionsStatesRef. Operations that modify
|
// this method uses a simple cache in collectionsStatesRef. Operations that modify
|
||||||
// cluster state should always reset this cache so that the changes become visible
|
// cluster state should always reset this cache so that the changes become visible
|
||||||
private Map<String, DocCollection> getCollectionStates() throws IOException {
|
private Map<String, DocCollection> getCollectionStates() throws IOException, InterruptedException {
|
||||||
lock.lock();
|
lock.lockInterruptibly();
|
||||||
try {
|
try {
|
||||||
Map<String, DocCollection> collectionStates = collectionsStatesRef.get();
|
Map<String, DocCollection> collectionStates = collectionsStatesRef.get();
|
||||||
if (collectionStates != null) {
|
if (collectionStates != null) {
|
||||||
|
|
Loading…
Reference in New Issue