Skip to content

Commit 53ddd34

Browse files
authored
Move logging shutdown to after waiting on node close (elastic#95093)
When Elasticsearch is shutting down, the Node instance is closed, and then logging is shutdown. However, some aspects of Node shutdown happen asynchronously, and awaiting that final close from the node occurs after shutting down logging. This commit moves logging shutdown to the very end of shutdown, to allow for as much information as possible to be logged if something goes wrong.
1 parent e832e63 commit 53ddd34

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

server/src/main/java/org/elasticsearch/bootstrap/Elasticsearch.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -446,8 +446,6 @@ private static void shutdown() {
446446
var es = INSTANCE;
447447
try {
448448
IOUtils.close(es.node, es.spawner);
449-
LoggerContext context = (LoggerContext) LogManager.getContext(false);
450-
Configurator.shutdown(context);
451449
if (es.node != null && es.node.awaitClose(10, TimeUnit.SECONDS) == false) {
452450
throw new IllegalStateException(
453451
"Node didn't stop within 10 seconds. " + "Any outstanding requests or tasks might get killed."
@@ -459,6 +457,9 @@ private static void shutdown() {
459457
LogManager.getLogger(Elasticsearch.class).warn("Thread got interrupted while waiting for the node to shutdown.");
460458
Thread.currentThread().interrupt();
461459
} finally {
460+
LoggerContext context = (LoggerContext) LogManager.getContext(false);
461+
Configurator.shutdown(context);
462+
462463
es.keepAliveLatch.countDown();
463464
}
464465
}

0 commit comments

Comments
 (0)