Skip to content

Commit 514c0d7

Browse files
Replace FailedToCommitClusterStateException with NotMasterException (#136083)
Replaces the `FailedToCommitClusterStateException` inside `MasterService .BatchingTaskQueue.submitTask` with a `NotMasterException`. Since this exception is thrown when the node is shutting down and closing its threadpools, it can no longer be the current master. Relates to: ES-13061
1 parent b1492f7 commit 514c0d7

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

server/src/main/java/org/elasticsearch/cluster/service/MasterService.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1607,13 +1607,7 @@ public void submitTask(String source, T task, @Nullable TimeValue timeout) {
16071607
} catch (Exception e) {
16081608
assert e instanceof EsRejectedExecutionException esre && esre.isExecutorShutdown() : e;
16091609
task.onFailure(
1610-
new FailedToCommitClusterStateException(
1611-
"could not schedule timeout handler for [%s][%s] on queue [%s]",
1612-
e,
1613-
source,
1614-
task,
1615-
name
1616-
)
1610+
new NotMasterException("could not schedule timeout handler for [%s][%s] on queue [%s]", e, source, task, name)
16171611
);
16181612
return;
16191613
}

server/src/test/java/org/elasticsearch/cluster/service/MasterServiceTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2249,7 +2249,7 @@ public void testTimeoutRejectionBehaviourAtSubmission() {
22492249
).submitTask(source, new ClusterStateTaskListener() {
22502250
@Override
22512251
public void onFailure(Exception e) {
2252-
if (e instanceof FailedToCommitClusterStateException
2252+
if (e instanceof NotMasterException
22532253
&& e.getMessage().startsWith("could not schedule timeout handler")
22542254
&& e.getCause() instanceof EsRejectedExecutionException esre
22552255
&& esre.isExecutorShutdown()

0 commit comments

Comments
 (0)