Skip to content

Commit

Permalink
Fix node close stopwatch usage (elastic#41918)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jaymode committed May 9, 2019
1 parent 9284a70 commit 2998c10
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions server/src/main/java/org/elasticsearch/node/Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -839,13 +839,15 @@ public synchronized void close() throws IOException {
// Don't call shutdownNow here, it might break ongoing operations on Lucene indices.
// See https://issues.apache.org/jira/browse/LUCENE-7248. We call shutdownNow in
// awaitClose if the node doesn't finish closing within the specified time.
toClose.add(() -> stopWatch.stop());
toClose.add(() -> stopWatch.stop().start("node_environment"));

toClose.add(injector.getInstance(NodeEnvironment.class));
toClose.add(() -> stopWatch.stop().start("page_cache_recycler"));
toClose.add(injector.getInstance(PageCacheRecycler.class));
toClose.add(stopWatch::stop);

if (logger.isTraceEnabled()) {
logger.trace("Close times for each service:\n{}", stopWatch.prettyPrint());
toClose.add(() -> logger.trace("Close times for each service:\n{}", stopWatch.prettyPrint()));
}
IOUtils.close(toClose);
logger.info("closed");
Expand Down

0 comments on commit 2998c10

Please sign in to comment.