From 16642f1c74b2716792a945f117a4ceee1f83838e Mon Sep 17 00:00:00 2001 From: Armin Braun Date: Tue, 1 Dec 2020 06:51:05 +0100 Subject: [PATCH] Handle RejectedExecutionException in ShardFollowTasksExecutor (#65648) (#65653) Follow-up to #65415. We can't have this exception bubble up in an exception handler any longer due to the new assertion so we must handle it here. --- .../xpack/ccr/action/ShardFollowTasksExecutor.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/ShardFollowTasksExecutor.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/ShardFollowTasksExecutor.java index 6e55d7b0c30..dd014c87c4f 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/ShardFollowTasksExecutor.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/ShardFollowTasksExecutor.java @@ -42,6 +42,7 @@ import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.SettingsModule; import org.elasticsearch.common.unit.TimeValue; +import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException; import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.index.Index; import org.elasticsearch.index.IndexNotFoundException; @@ -544,7 +545,12 @@ public class ShardFollowTasksExecutor extends PersistentTasksExecutor nodeOperation(task, params, state), params.getMaxRetryDelay(), Ccr.CCR_THREAD_POOL_NAME); + try { + threadPool.schedule(() -> nodeOperation(task, params, state), params.getMaxRetryDelay(), Ccr.CCR_THREAD_POOL_NAME); + } catch (EsRejectedExecutionException rex) { + rex.addSuppressed(e); + shardFollowNodeTask.onFatalFailure(rex); + } } else { shardFollowNodeTask.onFatalFailure(e); }