Skip to content

Commit 88f8b5c

Browse files
committed
[CCR] Check whether the rejected execution exception has the shutdown flag set (#33703)
and if so debug log it and otherwise rethrow. This should fix a couple of test failures where during test teardown tests failed due to uncaught exceptions being detected.
1 parent ea3d6f8 commit 88f8b5c

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.elasticsearch.cluster.routing.IndexRoutingTable;
2525
import org.elasticsearch.common.settings.Settings;
2626
import org.elasticsearch.common.unit.TimeValue;
27+
import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException;
2728
import org.elasticsearch.common.util.concurrent.ThreadContext;
2829
import org.elasticsearch.common.xcontent.XContentType;
2930
import org.elasticsearch.index.Index;
@@ -91,8 +92,17 @@ protected AllocatedPersistentTask createTask(long id, String type, String action
9192
leaderClient = wrapClient(client, params);
9293
}
9394
Client followerClient = wrapClient(client, params);
94-
BiConsumer<TimeValue, Runnable> scheduler =
95-
(delay, command) -> threadPool.schedule(delay, Ccr.CCR_THREAD_POOL_NAME, command);
95+
BiConsumer<TimeValue, Runnable> scheduler = (delay, command) -> {
96+
try {
97+
threadPool.schedule(delay, Ccr.CCR_THREAD_POOL_NAME, command);
98+
} catch (EsRejectedExecutionException e) {
99+
if (e.isExecutorShutdown()) {
100+
logger.debug("couldn't schedule command, executor is shutting down", e);
101+
} else {
102+
throw e;
103+
}
104+
}
105+
};
96106
return new ShardFollowNodeTask(
97107
id, type, action, getDescription(taskInProgress), parentTaskId, headers, params, scheduler, System::nanoTime) {
98108

0 commit comments

Comments
 (0)