Permalink
Browse files

now that the change to refresh can execute on not yet active shards, …

…we need to ignore illegal shard state failures (expected...)
  • Loading branch information...
1 parent d69baa3 commit 9c6dfc15082be8e86f2ed2e355ad46e16a75d082 @kimchy kimchy committed Oct 5, 2011
@@ -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.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 @@
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 @@ protected boolean accumulateExceptions() {
return true;
}
+ protected boolean ignoreException(Throwable t) {
+ return false;
+ }
+
protected boolean ignoreNonActiveExceptions() {
return false;
}
@@ -267,13 +271,15 @@ void performOperation(final ShardIterator shardIt, final ShardRouting shard, boo
@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 @@ void performOperation(final ShardIterator shardIt, final ShardRouting shard, boo
// 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 @@ void performOperation(final ShardIterator shardIt, final ShardRouting shard, boo
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);
}

0 comments on commit 9c6dfc1

Please sign in to comment.