Apache Solr open-source search software
SOLR-15010 Try to use jattach for threaddump if jstack is missing (#2192)
Eric Pugh3e2fb59272f5
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex 0f499e9c745..a62ca52eeee 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -227,7 +227,7 @@ Improvements* SOLR-14965: metrics: Adds two metrics to the SolrCloud Overseer: solr_metrics_overseer_stateUpdateQueueSizeand solr_metrics_overseer_collectionWorkQueueSize with corresponding entries in the the Prometheus exporter'sdefault/stock configuration. (Saatchi Bhalla, Megan Carey, Andrzej Białecki, David Smiley)-+* SOLR-14827: Refactor schema loading to not use XPath (noble)* SOLR-14987: Reuse HttpSolrClient per node vs. one per Solr core when using CloudSolrStream (Timothy Potter)@@ -259,7 +259,7 @@ OptimizationsPartial updates to nested documents and Realtime Get of child documents is now more reliable.(David Smiley, Thomas Wöckinger)-* SOLR-15036: Automatically wrap a facet expression with a select / rollup / sort / plist when using a+* SOLR-15036: Automatically wrap a facet expression with a select / rollup / sort / plist when using acollection alias with multiple collections and count|sum|min|max|avg metrics. (Timothy Potter)Bug Fixes@@ -348,6 +348,8 @@ Other Changes* SOLR-14999: New option for specifying the advertised Solr Port (hostPort). Still defaults to "jetty.port". (Houston Putman)+* SOLR-15010: Thread dump using jattach if available and jstack is missing. (Eric Pugh)+================== 8.7.0 ==================Consult the lucene/CHANGES.txt file for additional, low level, changes in this release.diff --git a/solr/bin/solr b/solr/bin/solrindex 24b1a4f5312..f6c723adc56 100755--- a/solr/bin/solr+++ b/solr/bin/solr@@ -110,9 +110,10 @@ elif [ -n "$JAVA_HOME" ]; thenJAVA="$java/java"if [ -x "$java/jstack" ]; thenJSTACK="$java/jstack"+ elif [ -x "$(command -v jattach)" ]; then+ JATTACH="$(command -v jattach)"else- echo >&2 "The currently defined JAVA_HOME ($JAVA_HOME) refers to a location"- echo >&2 "where java was found but jstack was not found. Continuing."+ echo >&2 "neither jattach nor jstack in $JAVA_HOME could be found, so no thread dumps are possible. Continuing."fibreakfi@@ -429,7 +430,7 @@ function print_usage() {echo ""echo " -c <collection> Collection to run healthcheck against."echo ""- echo " -z <zkHost> Zookeeper connection string; unnecessary if ZK_HOST is defined in solr.in.sh;"+ echo " -z <zkHost> Zookeeper connection string; unnecessary if ZK_HOST is defined in solr.in.sh;"echo " otherwise, default is localhost:9983"echo ""echo " -V Enable more verbose output"@@ -831,7 +832,7 @@ function run_package() {# tries to gracefully stop Solr using the Jetty# stop command and if that fails, then uses kill -9-# (will attempt to jstack before killing)+# (will attempt to thread dump before killing)function stop_solr() {DIR="$1"@@ -871,6 +872,9 @@ function stop_solr() {if [ "$JSTACK" != "" ]; thenecho -e "Solr process $SOLR_PID is still running; jstacking it now."$JSTACK $SOLR_PID+ elif [ "$JATTACH" != "" ]; then+ echo -e "Solr process $SOLR_PID is still running; jattach threaddumping it now."+ $JATTACH $SOLR_PID threaddumpfiecho -e "Solr process $SOLR_PID is still running; forcefully killing it now."kill -9 $SOLR_PIDdiff --git a/solr/docker/README.md b/solr/docker/README.mdindex 3356419d38c..583e8b02e4f 100644--- a/solr/docker/README.md+++ b/solr/docker/README.md@@ -226,8 +226,8 @@ Other ways of extending the image are to create custom Docker images that inheriThe `jcmd`, `jmap` `jstack` tools can be useful for debugging Solr inside the container. These tools are not included with the JRE, but this image includes the [jattach](https://github.com/apangin/jattach) utility which lets you do much of the same.Usage: jattach <pid> <cmd> [args ...]-- Commands:++ Commands:load : load agent libraryproperties : print system propertiesagentProperties : print agent properties@@ -238,8 +238,8 @@ The `jcmd`, `jmap` `jstack` tools can be useful for debugging Solr inside the cosetflag : modify manageable VM flagprintflag : print VM flagjcmd : execute jcmd command--Example comands to do a thread dump and get heap info for PID 10:++Example commands to do a thread dump and get heap info for PID 10:jattach 10 threaddumpjattach 10 jcmd GC.heap_info@@ -272,4 +272,4 @@ This repository is available on , and the official build is on the [Docker Hub](# History-This project was started in 2015 by [Martijn Koster](https://github.com/makuk66) in the [docker-solr](https://github.com/docker-solr/docker-solr) repository. In 2019 maintainership and copyright was transferred to the Apache Lucene/Solr project, and in 2020 the project was migrated to live within the Solr project. Many thanks to Martijn for all your contributions over the years!\ No newline at end of file+This project was started in 2015 by [Martijn Koster](https://github.com/makuk66) in the [docker-solr](https://github.com/docker-solr/docker-solr) repository. In 2019 maintainership and copyright was transferred to the Apache Lucene/Solr project, and in 2020 the project was migrated to live within the Solr project. Many thanks to Martijn for all your contributions over the years!