You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ep...@apache.org on 2021/01/11 19:58:32 UTC

[lucene-solr] branch master updated: SOLR-15010 Try to use jattach for threaddump if jstack is missing (#2192)

This is an automated email from the ASF dual-hosted git repository.

epugh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git


The following commit(s) were added to refs/heads/master by this push:
     new 3e2fb59  SOLR-15010 Try to use jattach for threaddump if jstack is missing (#2192)
3e2fb59 is described below

commit 3e2fb59272f5b4d8106b3d8edf847f50bacd7a61
Author: Eric Pugh <ep...@opensourceconnections.com>
AuthorDate: Mon Jan 11 14:58:11 2021 -0500

    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 <cp...@apache.org>
---
 solr/CHANGES.txt      |  6 ++++--
 solr/bin/solr         | 12 ++++++++----
 solr/docker/README.md | 10 +++++-----
 3 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 0f499e9..a62ca52 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_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.
diff --git a/solr/bin/solr b/solr/bin/solr
index 24b1a4f..f6c723a 100755
--- a/solr/bin/solr
+++ b/solr/bin/solr
@@ -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
diff --git a/solr/docker/README.md b/solr/docker/README.md
index 3356419..583e8b0 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 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!
\ 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!