From be72e482acc3281d826eb7d4da98992d0c7e8a12 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Tue, 6 Jun 2023 18:26:28 +0100 Subject: [PATCH] Print thread dumps when PR build is cancelled Closes gh-35760 --- .github/actions/print-jvm-thread-dumps/action.yml | 14 ++++++++++++++ .github/workflows/build-pull-request.yml | 4 ++++ 2 files changed, 18 insertions(+) create mode 100644 .github/actions/print-jvm-thread-dumps/action.yml diff --git a/.github/actions/print-jvm-thread-dumps/action.yml b/.github/actions/print-jvm-thread-dumps/action.yml new file mode 100644 index 0000000000..ff7284fd1f --- /dev/null +++ b/.github/actions/print-jvm-thread-dumps/action.yml @@ -0,0 +1,14 @@ +name: Print JVM thread dumps +description: Prints a thread dump for all running JVMs +runs: + using: composite + steps: + - run: | + for java_pid in $(jps -q -J-XX:+PerfDisableSharedMem); do + echo "------------------------ pid $java_pid ------------------------" + cat /proc/$java_pid/cmdline | xargs -0 echo + jcmd $java_pid Thread.print -l + jcmd $java_pid GC.heap_info + done + exit 0 + shell: bash \ No newline at end of file diff --git a/.github/workflows/build-pull-request.yml b/.github/workflows/build-pull-request.yml index be95448fa3..52bb7d9834 100644 --- a/.github/workflows/build-pull-request.yml +++ b/.github/workflows/build-pull-request.yml @@ -30,3 +30,7 @@ jobs: CI: 'true' GRADLE_ENTERPRISE_URL: 'https://ge.spring.io' run: ./gradlew -Dorg.gradle.internal.launcher.welcomeMessageEnabled=false --no-daemon --max-workers=4 --continue build + + - name: Print JVM thread dumps when cancelled + uses: ./.github/actions/print-jvm-thread-dumps + if: cancelled()