now that the change to refresh can execute on not yet active shards, we need to ignore illegal shard state failures (expected...)
This commit is contained in:
parent
d69baa3e04
commit
9c6dfc1508
|
@ -20,6 +20,7 @@
|
|||
package org.elasticsearch.action.admin.indices.refresh;
|
||||
|
||||
import org.elasticsearch.ElasticSearchException;
|
||||
import org.elasticsearch.ExceptionsHelper;
|
||||
import org.elasticsearch.action.ShardOperationFailedException;
|
||||
import org.elasticsearch.action.TransportActions;
|
||||
import org.elasticsearch.action.support.DefaultShardOperationFailedException;
|
||||
|
@ -32,6 +33,7 @@ import org.elasticsearch.cluster.routing.ShardRouting;
|
|||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.index.engine.Engine;
|
||||
import org.elasticsearch.index.shard.IllegalIndexShardStateException;
|
||||
import org.elasticsearch.index.shard.service.IndexShard;
|
||||
import org.elasticsearch.indices.IndicesService;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
|
@ -77,6 +79,14 @@ public class TransportRefreshAction extends TransportBroadcastOperationAction<Re
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override protected boolean ignoreException(Throwable t) {
|
||||
Throwable actual = ExceptionsHelper.unwrapCause(t);
|
||||
if (actual instanceof IllegalIndexShardStateException) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override protected RefreshResponse newResponse(RefreshRequest request, AtomicReferenceArray shardsResponses, ClusterState clusterState) {
|
||||
int successfulShards = 0;
|
||||
int failedShards = 0;
|
||||
|
|
|
@ -99,6 +99,10 @@ public abstract class TransportBroadcastOperationAction<Request extends Broadcas
|
|||
return true;
|
||||
}
|
||||
|
||||
protected boolean ignoreException(Throwable t) {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean ignoreNonActiveExceptions() {
|
||||
return false;
|
||||
}
|
||||
|
@ -267,13 +271,15 @@ public abstract class TransportBroadcastOperationAction<Request extends Broadcas
|
|||
@SuppressWarnings({"unchecked"}) void onOperation(@Nullable ShardRouting shard, final ShardIterator shardIt, Throwable t) {
|
||||
ShardRouting nextShard = shardIt.nextOrNull();
|
||||
if (nextShard != null) {
|
||||
// trace log this exception
|
||||
if (logger.isTraceEnabled()) {
|
||||
if (t != null) {
|
||||
if (shard != null) {
|
||||
logger.trace(shard.shortSummary() + ": Failed to execute [" + request + "]", t);
|
||||
} else {
|
||||
logger.trace(shardIt.shardId() + ": Failed to execute [" + request + "]", t);
|
||||
if (t != null) {
|
||||
// trace log this exception
|
||||
if (logger.isTraceEnabled()) {
|
||||
if (!ignoreException(t)) {
|
||||
if (shard != null) {
|
||||
logger.trace(shard.shortSummary() + ": Failed to execute [" + request + "]", t);
|
||||
} else {
|
||||
logger.trace(shardIt.shardId() + ": Failed to execute [" + request + "]", t);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -286,10 +292,12 @@ public abstract class TransportBroadcastOperationAction<Request extends Broadcas
|
|||
// e is null when there is no next active....
|
||||
if (logger.isDebugEnabled()) {
|
||||
if (t != null) {
|
||||
if (shard != null) {
|
||||
logger.debug(shard.shortSummary() + ": Failed to execute [" + request + "]", t);
|
||||
} else {
|
||||
logger.debug(shardIt.shardId() + ": Failed to execute [" + request + "]", t);
|
||||
if (!ignoreException(t)) {
|
||||
if (shard != null) {
|
||||
logger.debug(shard.shortSummary() + ": Failed to execute [" + request + "]", t);
|
||||
} else {
|
||||
logger.debug(shardIt.shardId() + ": Failed to execute [" + request + "]", t);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -300,8 +308,14 @@ public abstract class TransportBroadcastOperationAction<Request extends Broadcas
|
|||
if (!ignoreNonActiveExceptions()) {
|
||||
t = new BroadcastShardOperationFailedException(shardIt.shardId(), "No active shard(s)");
|
||||
}
|
||||
} else if (!(t instanceof BroadcastShardOperationFailedException)) {
|
||||
t = new BroadcastShardOperationFailedException(shardIt.shardId(), t);
|
||||
} else {
|
||||
if (ignoreException(t)) {
|
||||
t = null;
|
||||
} else {
|
||||
if (!(t instanceof BroadcastShardOperationFailedException)) {
|
||||
t = new BroadcastShardOperationFailedException(shardIt.shardId(), t);
|
||||
}
|
||||
}
|
||||
}
|
||||
shardsResponses.set(index, t);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue