Skip to content

Commit 050bdfc

Browse files
committed
Log failure when cleaning shard follow task (#51971)
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.
1 parent 33a05e2 commit 050bdfc

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/ShardFollowTaskCleaner.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import org.apache.logging.log4j.LogManager;
1010
import org.apache.logging.log4j.Logger;
11+
import org.apache.logging.log4j.message.ParameterizedMessage;
1112
import org.elasticsearch.action.ActionListener;
1213
import org.elasticsearch.client.Client;
1314
import org.elasticsearch.cluster.ClusterChangedEvent;
@@ -63,9 +64,9 @@ public void clusterChanged(final ClusterChangedEvent event) {
6364
// the index exists, do not clean this persistent task
6465
continue;
6566
}
66-
IndexNotFoundException e = new IndexNotFoundException(followerIndex);
67+
IndexNotFoundException infe = new IndexNotFoundException(followerIndex);
6768
CompletionPersistentTaskAction.Request request =
68-
new CompletionPersistentTaskAction.Request(persistentTask.getId(), persistentTask.getAllocationId(), e);
69+
new CompletionPersistentTaskAction.Request(persistentTask.getId(), persistentTask.getAllocationId(), infe);
6970
threadPool.generic().submit(() -> {
7071
client.execute(CompletionPersistentTaskAction.INSTANCE, request, new ActionListener<PersistentTaskResponse>() {
7172

@@ -76,7 +77,7 @@ public void onResponse(PersistentTaskResponse persistentTaskResponse) {
7677

7778
@Override
7879
public void onFailure(Exception e) {
79-
logger.warn("failed to clean up task [{}]", persistentTask.getId());
80+
logger.warn(new ParameterizedMessage("failed to clean up task [{}]", persistentTask.getId()), e);
8081
}
8182
});
8283
});

0 commit comments

Comments
 (0)