Skip to content

Commit 8aba868

Browse files
committed
Terminate ES on NodeDoesNotExistOnMasterException
1 parent c6ac5ac commit 8aba868

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

src/main/java/org/elasticsearch/discovery/zen/fd/MasterFaultDetection.java

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,9 +312,26 @@ public void handleException(TransportException exp) {
312312
notifyMasterFailure(masterToPing, "not master");
313313
return;
314314
} else if (exp.getCause() instanceof NodeDoesNotExistOnMasterException) {
315-
logger.debug("[master] pinging a master {} but we do not exists on it, act as if its master failure", masterNode);
316-
notifyMasterFailure(masterToPing, "do not exists on master, act as master failure");
317-
return;
315+
logger.info("[master] pinging a master {} but we do not exists on it, and we do not want election to take place", masterNode);
316+
logger.info("Exiting as we are no longer present on master");
317+
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
318+
319+
@Override
320+
public void run() {
321+
try {
322+
Thread.sleep(30000);
323+
System.err.println("Process not killed in 30s, halting");
324+
logger.info("Process not killed in 30s, halting");
325+
Runtime.getRuntime().halt(1);
326+
} catch (InterruptedException e) {
327+
System.err.println("Process not killed in 30s, halting");
328+
Runtime.getRuntime().halt(1);
329+
}
330+
331+
332+
}
333+
}));
334+
System.exit(0);
318335
}
319336
int retryCount = ++MasterFaultDetection.this.retryCount;
320337
logger.trace("[master] failed to ping [{}], retry [{}] out of [{}]", exp, masterNode, retryCount, pingRetryCount);

0 commit comments

Comments
 (0)