Skip to content

Commit beb7c9e

Browse files
authored
Handle rejection in FollowerChecker (#84484)
In #83576 we moved cluster coordination activities to a threadpool which rejects actions on shutdown. #84483 is a test failure caused by a missing rejection handler, which this commit addresses. Closes #84483
1 parent 23a7b6b commit beb7c9e

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

server/src/main/java/org/elasticsearch/cluster/coordination/FollowersChecker.java

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.elasticsearch.common.settings.Setting;
2020
import org.elasticsearch.common.settings.Settings;
2121
import org.elasticsearch.common.util.concurrent.AbstractRunnable;
22+
import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException;
2223
import org.elasticsearch.core.TimeValue;
2324
import org.elasticsearch.monitor.NodeHealthService;
2425
import org.elasticsearch.monitor.StatusInfo;
@@ -358,9 +359,20 @@ public void handleException(TransportException exp) {
358359
}
359360

360361
void failNode(String reason) {
361-
transportService.getThreadPool().executor(Names.CLUSTER_COORDINATION).execute(new Runnable() {
362+
transportService.getThreadPool().executor(Names.CLUSTER_COORDINATION).execute(new AbstractRunnable() {
363+
362364
@Override
363-
public void run() {
365+
public void onRejection(Exception e) {
366+
logger.debug(new ParameterizedMessage("rejected task to fail node [{}] with reason [{}]", discoveryNode, reason), e);
367+
if (e instanceof EsRejectedExecutionException esRejectedExecutionException) {
368+
assert esRejectedExecutionException.isExecutorShutdown();
369+
} else {
370+
assert false : e;
371+
}
372+
}
373+
374+
@Override
375+
protected void doRun() {
364376
synchronized (mutex) {
365377
if (running() == false) {
366378
logger.trace("{} no longer running, not marking faulty", FollowerChecker.this);
@@ -373,6 +385,15 @@ public void run() {
373385
onNodeFailure.accept(discoveryNode, reason);
374386
}
375387

388+
@Override
389+
public void onFailure(Exception e) {
390+
assert false : e;
391+
logger.error(
392+
new ParameterizedMessage("unexpected failure when failing node [{}] with reason [{}]", discoveryNode, reason),
393+
e
394+
);
395+
}
396+
376397
@Override
377398
public String toString() {
378399
return "detected failure of " + discoveryNode;

0 commit comments

Comments
 (0)