Capturing Jstacks from Bitbucket Mesh Sidecar on Startup

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform Notice: Data Center - This article applies to Atlassian products on the Data Center platform.

Note that this knowledge base article was created for the Data Center version of the product. Data Center knowledge base articles for non-Data Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Purpose

Bitbucket Mesh Sidecar may fail to start up or experience a delay in starting up which can cause the connection from Bitbucket to timeout. Because Sidecar handles the local SCM tasks for Bitbucket, this failure can result in startup failures with the Web UI displaying an error such as:  

SpringMVC dispatch springMVC could not be started


If logging is not sufficient to diagnose the issue, Support may request for Jstacks. This may be difficult to capture during startup because the child process is spawned by Bitbucket. To assist with this, we can use a bash script such as the following:

count=1; while true; do
    MESH_PID=$(pgrep -f mesh-app.jar | head -n1)
    TS=$(date +%s)
    if [ -n "$MESH_PID" ]; then
        jstack -l $MESH_PID >> "bb-sidecar-jstack-$count-$TS.out"
        echo "Captured jstack $count at $TS"
        ((count++))
        sleep 5s
    fi
done
  • The count variable is used to hold the iteration
  • We capture the PID for Sidecar using the pgrep  command
  • We then use the TS variable to capture the timestamp for each Jstack

NOTE: This command should be run as the user running Bitbucket (i.e. atlbitbucket)

Example

[atlbitbucket]$ count=1; while true; do
     MESH_PID=$(pgrep -f mesh-app.jar | head -n1)
     TS=$(date +%s)
     if [ -n "$MESH_PID" ]; then
         jstack -l $MESH_PID >> "bb-sidecar-jstack-$count-$TS.out"
         echo "Captured jstack $count at $TS"
         ((count++))
         sleep 5s
     fi
 done

Captured jstack 1 at 1706633261
Captured jstack 2 at 1706633267
Captured jstack 3 at 1706633272
Captured jstack 4 at 1706633277
Captured jstack 5 at 1706633282
Captured jstack 6 at 1706633288
Captured jstack 7 at 1706633293
Captured jstack 8 at 1706633298
Captured jstack 9 at 1706633303
Captured jstack 10 at 1706633309
^C

[atlbitbucket]$ tar cvzf bb-sidecar-jstacks.tar.gz bb-sidecar-jstack-*

CTRL+C  can be used to exit the loop and the tar  command can be used to collect and compress the Jstacks for upload to the Support case. 

Last modified on Jan 30, 2024

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.