Skip to content

Commit 11c45d3

Browse files
committed
now that the change to refresh can execute on not yet active shards, we need to ignore illegal shard state failures (expected...)
1 parent 900fb48 commit 11c45d3

File tree

2 files changed

+37
-13
lines changed

2 files changed

+37
-13
lines changed

modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/refresh/TransportRefreshAction.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
package org.elasticsearch.action.admin.indices.refresh;
2121

2222
import org.elasticsearch.ElasticSearchException;
23+
import org.elasticsearch.ExceptionsHelper;
2324
import org.elasticsearch.action.ShardOperationFailedException;
2425
import org.elasticsearch.action.TransportActions;
2526
import org.elasticsearch.action.support.DefaultShardOperationFailedException;
@@ -32,6 +33,7 @@
3233
import org.elasticsearch.common.inject.Inject;
3334
import org.elasticsearch.common.settings.Settings;
3435
import org.elasticsearch.index.engine.Engine;
36+
import org.elasticsearch.index.shard.IllegalIndexShardStateException;
3537
import org.elasticsearch.index.shard.service.IndexShard;
3638
import org.elasticsearch.indices.IndicesService;
3739
import org.elasticsearch.threadpool.ThreadPool;
@@ -77,6 +79,14 @@ public class TransportRefreshAction extends TransportBroadcastOperationAction<Re
7779
return true;
7880
}
7981

82+
@Override protected boolean ignoreException(Throwable t) {
83+
Throwable actual = ExceptionsHelper.unwrapCause(t);
84+
if (actual instanceof IllegalIndexShardStateException) {
85+
return true;
86+
}
87+
return false;
88+
}
89+
8090
@Override protected RefreshResponse newResponse(RefreshRequest request, AtomicReferenceArray shardsResponses, ClusterState clusterState) {
8191
int successfulShards = 0;
8292
int failedShards = 0;

modules/elasticsearch/src/main/java/org/elasticsearch/action/support/broadcast/TransportBroadcastOperationAction.java

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ protected boolean accumulateExceptions() {
9999
return true;
100100
}
101101

102+
protected boolean ignoreException(Throwable t) {
103+
return false;
104+
}
105+
102106
protected boolean ignoreNonActiveExceptions() {
103107
return false;
104108
}
@@ -267,13 +271,15 @@ void performOperation(final ShardIterator shardIt, final ShardRouting shard, boo
267271
@SuppressWarnings({"unchecked"}) void onOperation(@Nullable ShardRouting shard, final ShardIterator shardIt, Throwable t) {
268272
ShardRouting nextShard = shardIt.nextOrNull();
269273
if (nextShard != null) {
270-
// trace log this exception
271-
if (logger.isTraceEnabled()) {
272-
if (t != null) {
273-
if (shard != null) {
274-
logger.trace(shard.shortSummary() + ": Failed to execute [" + request + "]", t);
275-
} else {
276-
logger.trace(shardIt.shardId() + ": Failed to execute [" + request + "]", t);
274+
if (t != null) {
275+
// trace log this exception
276+
if (logger.isTraceEnabled()) {
277+
if (!ignoreException(t)) {
278+
if (shard != null) {
279+
logger.trace(shard.shortSummary() + ": Failed to execute [" + request + "]", t);
280+
} else {
281+
logger.trace(shardIt.shardId() + ": Failed to execute [" + request + "]", t);
282+
}
277283
}
278284
}
279285
}
@@ -286,10 +292,12 @@ void performOperation(final ShardIterator shardIt, final ShardRouting shard, boo
286292
// e is null when there is no next active....
287293
if (logger.isDebugEnabled()) {
288294
if (t != null) {
289-
if (shard != null) {
290-
logger.debug(shard.shortSummary() + ": Failed to execute [" + request + "]", t);
291-
} else {
292-
logger.debug(shardIt.shardId() + ": Failed to execute [" + request + "]", t);
295+
if (!ignoreException(t)) {
296+
if (shard != null) {
297+
logger.debug(shard.shortSummary() + ": Failed to execute [" + request + "]", t);
298+
} else {
299+
logger.debug(shardIt.shardId() + ": Failed to execute [" + request + "]", t);
300+
}
293301
}
294302
}
295303
}
@@ -300,8 +308,14 @@ void performOperation(final ShardIterator shardIt, final ShardRouting shard, boo
300308
if (!ignoreNonActiveExceptions()) {
301309
t = new BroadcastShardOperationFailedException(shardIt.shardId(), "No active shard(s)");
302310
}
303-
} else if (!(t instanceof BroadcastShardOperationFailedException)) {
304-
t = new BroadcastShardOperationFailedException(shardIt.shardId(), t);
311+
} else {
312+
if (ignoreException(t)) {
313+
t = null;
314+
} else {
315+
if (!(t instanceof BroadcastShardOperationFailedException)) {
316+
t = new BroadcastShardOperationFailedException(shardIt.shardId(), t);
317+
}
318+
}
305319
}
306320
shardsResponses.set(index, t);
307321
}

0 commit comments

Comments
 (0)