Skip to content

Commit

Permalink
log hot threads if node fails to close in time
Browse files Browse the repository at this point in the history
  • Loading branch information
ywangd committed Sep 13, 2024
1 parent 2306a41 commit 44ea009
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion server/src/main/java/org/elasticsearch/node/Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
import org.elasticsearch.indices.store.IndicesStore;
import org.elasticsearch.injection.guice.Injector;
import org.elasticsearch.monitor.fs.FsHealthService;
import org.elasticsearch.monitor.jvm.HotThreads;
import org.elasticsearch.monitor.jvm.JvmInfo;
import org.elasticsearch.monitor.metrics.NodeMetrics;
import org.elasticsearch.node.internal.TerminationHandler;
Expand Down Expand Up @@ -92,6 +93,7 @@
import java.io.Closeable;
import java.io.File;
import java.io.IOException;
import java.io.StringWriter;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.nio.charset.Charset;
Expand All @@ -111,7 +113,6 @@
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collectors;

import javax.net.ssl.SNIHostName;

import static org.elasticsearch.core.Strings.format;
Expand Down Expand Up @@ -724,6 +725,13 @@ public synchronized boolean awaitClose(long timeout, TimeUnit timeUnit) throws I
+ "Something is leaking index readers or store references."
);
}
} else {
try (var writer = new StringWriter()) {
new HotThreads().busiestThreads(9999).ignoreIdleThreads(false).detect(writer);
logger.info("--> hot threads failing close node:\n{}\n", writer.toString());
} catch (Exception e) {
logger.info("--> fail to log hot threads failing close node [{}]", e.getMessage());
}
}
return terminated;
}
Expand Down

0 comments on commit 44ea009

Please sign in to comment.