SOLR-15010 Try to use jattach for threaddump if jstack is missing (#2192)

* introduce jattach check if jstack is missing.  jattach ships in the Solr docker image instead of jstack.
* get the full path to the jattach command

Co-authored-by: Christine Poerschke <cpoerschke@apache.org>
This commit is contained in:
Eric Pugh 2021-01-11 14:58:11 -05:00 committed by GitHub
parent a429b969d8
commit 3e2fb59272
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 11 deletions

View File

@ -227,7 +227,7 @@ Improvements
* SOLR-14965: metrics: Adds two metrics to the SolrCloud Overseer: solr_metrics_overseer_stateUpdateQueueSize
and solr_metrics_overseer_collectionWorkQueueSize with corresponding entries in the the Prometheus exporter's
default/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 @@ Optimizations
Partial 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 a
collection 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.

View File

@ -110,9 +110,10 @@ elif [ -n "$JAVA_HOME" ]; then
JAVA="$java/java"
if [ -x "$java/jstack" ]; then
JSTACK="$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."
fi
break
fi
@ -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" != "" ]; then
echo -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 threaddump
fi
echo -e "Solr process $SOLR_PID is still running; forcefully killing it now."
kill -9 $SOLR_PID

View File

@ -226,8 +226,8 @@ Other ways of extending the image are to create custom Docker images that inheri
The `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 library
properties : print system properties
agentProperties : print agent properties
@ -238,8 +238,8 @@ The `jcmd`, `jmap` `jstack` tools can be useful for debugging Solr inside the co
setflag : modify manageable VM flag
printflag : print VM flag
jcmd : 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 threaddump
jattach 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!
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!