From a5bc5ae030bd46f50dde1fcc51ebb898c1cfb6a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Fern=C3=A1ndez=20Casta=C3=B1o?= <francisco.fernandez.castano@gmail.com> Date: Tue, 16 Jun 2020 14:04:32 +0200 Subject: [PATCH] Don't log on RetentionLeaseSync error handler (#58157) 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 #57864 Backport of (#58098) --- .../index/seqno/RetentionLeaseBackgroundSyncAction.java | 8 ++++++-- .../index/seqno/RetentionLeaseSyncAction.java | 6 +++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/index/seqno/RetentionLeaseBackgroundSyncAction.java b/server/src/main/java/org/elasticsearch/index/seqno/RetentionLeaseBackgroundSyncAction.java index e4b82b34175..ed0f6efaf4d 100644 --- a/server/src/main/java/org/elasticsearch/index/seqno/RetentionLeaseBackgroundSyncAction.java +++ b/server/src/main/java/org/elasticsearch/index/seqno/RetentionLeaseBackgroundSyncAction.java @@ -39,6 +39,7 @@ import org.elasticsearch.common.io.stream.StreamOutput; 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; @@ -137,8 +138,11 @@ public class RetentionLeaseBackgroundSyncAction extends TransportReplicationActi // 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); diff --git a/server/src/main/java/org/elasticsearch/index/seqno/RetentionLeaseSyncAction.java b/server/src/main/java/org/elasticsearch/index/seqno/RetentionLeaseSyncAction.java index 6b906792afc..b595a679329 100644 --- a/server/src/main/java/org/elasticsearch/index/seqno/RetentionLeaseSyncAction.java +++ b/server/src/main/java/org/elasticsearch/index/seqno/RetentionLeaseSyncAction.java @@ -41,6 +41,7 @@ import org.elasticsearch.common.io.stream.StreamOutput; 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; @@ -130,7 +131,10 @@ public class RetentionLeaseSyncAction extends @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");