Skip to content

Commit

Permalink
Handle rejection in LeaderChecker (elastic#89326)
Browse files Browse the repository at this point in the history
  • Loading branch information
DaveCTurner authored Aug 15, 2022
1 parent 104ad7f commit 51f89f4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.concurrent.AbstractRunnable;
import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException;
import org.elasticsearch.core.Nullable;
import org.elasticsearch.core.Releasable;
import org.elasticsearch.core.TimeValue;
Expand Down Expand Up @@ -331,12 +333,26 @@ public void handleException(TransportException exp) {

void leaderFailed(Supplier<String> messageSupplier, Exception e) {
if (isClosed.compareAndSet(false, true)) {
transportService.getThreadPool().executor(Names.CLUSTER_COORDINATION).execute(new Runnable() {
transportService.getThreadPool().executor(Names.CLUSTER_COORDINATION).execute(new AbstractRunnable() {
@Override
public void run() {
protected void doRun() {
leaderFailureListener.onLeaderFailure(messageSupplier, e);
}

@Override
public void onRejection(Exception e2) {
e.addSuppressed(e2);
logger.debug("rejected execution of onLeaderFailure", e);
assert e2 instanceof EsRejectedExecutionException esre && esre.isExecutorShutdown() : e;
}

@Override
public void onFailure(Exception e2) {
e2.addSuppressed(e);
logger.error("failed execution of onLeaderFailure", e2);
assert false : e2;
}

@Override
public String toString() {
return "notification of leader failure: " + e.getMessage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,7 @@ private static <T extends TransportResponse> void handleSendRequestException(
// should not happen
innerException.addSuppressed(transportException);
logger.error("unexpected exception from handler.handleException", innerException);
// assert false : innerException; TODO AwaitsFix https://github.com/elastic/elasticsearch/issues/89325
assert false : innerException;
}
}

Expand Down

0 comments on commit 51f89f4

Please sign in to comment.