From 6264cabe33bd93c75a52a11db438d181bdf48994 Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Wed, 5 Feb 2020 19:45:08 -0500 Subject: [PATCH] Log failure when cleaning shard follow task When clenaing a shard follow task after an index has been deleted, an exception can occur submitting the complete persistent task action. However, this exception message is not logged. This commit addresses this by including the exception that led to the failure in the log message. --- .../xpack/ccr/action/ShardFollowTaskCleaner.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/ShardFollowTaskCleaner.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/ShardFollowTaskCleaner.java index af704b6741727..8da545e82d157 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/ShardFollowTaskCleaner.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/ShardFollowTaskCleaner.java @@ -8,6 +8,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.message.ParameterizedMessage; import org.elasticsearch.action.ActionListener; import org.elasticsearch.client.Client; import org.elasticsearch.cluster.ClusterChangedEvent; @@ -63,9 +64,9 @@ public void clusterChanged(final ClusterChangedEvent event) { // the index exists, do not clean this persistent task continue; } - IndexNotFoundException e = new IndexNotFoundException(followerIndex); + IndexNotFoundException infe = new IndexNotFoundException(followerIndex); CompletionPersistentTaskAction.Request request = - new CompletionPersistentTaskAction.Request(persistentTask.getId(), persistentTask.getAllocationId(), e); + new CompletionPersistentTaskAction.Request(persistentTask.getId(), persistentTask.getAllocationId(), infe); threadPool.generic().submit(() -> { client.execute(CompletionPersistentTaskAction.INSTANCE, request, new ActionListener<>() { @@ -76,7 +77,7 @@ public void onResponse(PersistentTaskResponse persistentTaskResponse) { @Override public void onFailure(Exception e) { - logger.warn("failed to clean up task [{}]", persistentTask.getId()); + logger.warn(new ParameterizedMessage("failed to clean up task [{}]", persistentTask.getId()), e); } }); });