mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-09 06:25:07 +00:00
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,9 +271,10 @@ 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) {
|
||||
if (t != null) {
|
||||
// trace log this exception
|
||||
if (logger.isTraceEnabled()) {
|
||||
if (t != null) {
|
||||
if (!ignoreException(t)) {
|
||||
if (shard != null) {
|
||||
logger.trace(shard.shortSummary() + ": Failed to execute [" + request + "]", t);
|
||||
} else {
|
||||
@ -277,6 +282,7 @@ public abstract class TransportBroadcastOperationAction<Request extends Broadcas
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// we are not threaded here if we got here from the transport
|
||||
// or we possibly threaded if we got from a local threaded one,
|
||||
// in which case, the next shard in the partition will not be local one
|
||||
@ -286,6 +292,7 @@ public abstract class TransportBroadcastOperationAction<Request extends Broadcas
|
||||
// e is null when there is no next active....
|
||||
if (logger.isDebugEnabled()) {
|
||||
if (t != null) {
|
||||
if (!ignoreException(t)) {
|
||||
if (shard != null) {
|
||||
logger.debug(shard.shortSummary() + ": Failed to execute [" + request + "]", t);
|
||||
} else {
|
||||
@ -293,6 +300,7 @@ public abstract class TransportBroadcastOperationAction<Request extends Broadcas
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// no more shards in this group
|
||||
int index = indexCounter.getAndIncrement();
|
||||
if (accumulateExceptions()) {
|
||||
@ -300,9 +308,15 @@ public abstract class TransportBroadcastOperationAction<Request extends Broadcas
|
||||
if (!ignoreNonActiveExceptions()) {
|
||||
t = new BroadcastShardOperationFailedException(shardIt.shardId(), "No active shard(s)");
|
||||
}
|
||||
} else if (!(t instanceof BroadcastShardOperationFailedException)) {
|
||||
} else {
|
||||
if (ignoreException(t)) {
|
||||
t = null;
|
||||
} else {
|
||||
if (!(t instanceof BroadcastShardOperationFailedException)) {
|
||||
t = new BroadcastShardOperationFailedException(shardIt.shardId(), t);
|
||||
}
|
||||
}
|
||||
}
|
||||
shardsResponses.set(index, t);
|
||||
}
|
||||
if (expectedOps == counterOps.incrementAndGet()) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user