Skip to content

Commit 3911770

Browse files
authored
Fix node close stopwatch usage (#41918)
The close method in Node uses a StopWatch to time to closing of various services. However, the call to log the timing was made before any of the services had been closed and therefore no timing would be printed out. This change moves the timing log call to be a closeable that is the last item closed.
1 parent 335ed64 commit 3911770

File tree

1 file changed

+4
-2
lines changed
  • server/src/main/java/org/elasticsearch/node

1 file changed

+4
-2
lines changed

server/src/main/java/org/elasticsearch/node/Node.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -841,13 +841,15 @@ public synchronized void close() throws IOException {
841841
// Don't call shutdownNow here, it might break ongoing operations on Lucene indices.
842842
// See https://issues.apache.org/jira/browse/LUCENE-7248. We call shutdownNow in
843843
// awaitClose if the node doesn't finish closing within the specified time.
844-
toClose.add(() -> stopWatch.stop());
844+
toClose.add(() -> stopWatch.stop().start("node_environment"));
845845

846846
toClose.add(injector.getInstance(NodeEnvironment.class));
847+
toClose.add(() -> stopWatch.stop().start("page_cache_recycler"));
847848
toClose.add(injector.getInstance(PageCacheRecycler.class));
849+
toClose.add(stopWatch::stop);
848850

849851
if (logger.isTraceEnabled()) {
850-
logger.trace("Close times for each service:\n{}", stopWatch.prettyPrint());
852+
toClose.add(() -> logger.trace("Close times for each service:\n{}", stopWatch.prettyPrint()));
851853
}
852854
IOUtils.close(toClose);
853855
logger.info("closed");

0 commit comments

Comments
 (0)