Skip to content

Commit

Permalink
Don't log on RetentionLeaseSync error handler
Browse files Browse the repository at this point in the history
After an index has been deleted it may take some time to cancel all the
maintenance tasks such as RetentionLeaseSync, it's possible that the
task is already executing before the cancellation. This commit just
avoids logging a warning message for those scenarios.

Closes elastic#57864

Backport of (elastic#58098)
  • Loading branch information
fcofdez committed Jun 16, 2020
1 parent e046b0a commit a4ed318
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Expand Up @@ -39,6 +39,7 @@
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.gateway.WriteStateException;
import org.elasticsearch.index.IndexNotFoundException;
import org.elasticsearch.index.shard.IndexShard;
import org.elasticsearch.index.shard.IndexShardClosedException;
import org.elasticsearch.index.shard.ShardId;
Expand Down Expand Up @@ -137,8 +138,11 @@ public void handleException(TransportException e) {
// node shutting down
return;
}
if (ExceptionsHelper.unwrap(e, AlreadyClosedException.class, IndexShardClosedException.class) != null) {
// the shard is closed
if (ExceptionsHelper.unwrap(e,
IndexNotFoundException.class,
AlreadyClosedException.class,
IndexShardClosedException.class) != null) {
// the index was deleted or the shard is closed
return;
}
getLogger().warn(new ParameterizedMessage("{} retention lease background sync failed", shardId), e);
Expand Down
Expand Up @@ -41,6 +41,7 @@
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.gateway.WriteStateException;
import org.elasticsearch.index.IndexNotFoundException;
import org.elasticsearch.index.shard.IndexShard;
import org.elasticsearch.index.shard.IndexShardClosedException;
import org.elasticsearch.index.shard.ShardId;
Expand Down Expand Up @@ -130,7 +131,10 @@ public void handleResponse(ReplicationResponse response) {

@Override
public void handleException(TransportException e) {
if (ExceptionsHelper.unwrap(e, AlreadyClosedException.class, IndexShardClosedException.class) == null) {
if (ExceptionsHelper.unwrap(e,
IndexNotFoundException.class,
AlreadyClosedException.class,
IndexShardClosedException.class) == null) {
getLogger().warn(new ParameterizedMessage("{} retention lease sync failed", shardId), e);
}
task.setPhase("finished");
Expand Down

0 comments on commit a4ed318

Please sign in to comment.