diff --git a/.github/actions/thread-dump-jvms/action.yml b/.github/actions/thread-dump-jvms/action.yml new file mode 100644 index 00000000000..4a737e97701 --- /dev/null +++ b/.github/actions/thread-dump-jvms/action.yml @@ -0,0 +1,47 @@ +# ---------------------------------------------------------------------------- +# Copyright 2023 The Netty Project +# +# The Netty Project licenses this file to you under the Apache License, +# version 2.0 (the "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at: +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- +name: thread dump jvms +description: Triggers a thread dump for all running JVMs +runs: + using: composite + steps: + - run: | + if [[ "$OSTYPE" == "linux-gnu"* ]] && command -v sudo &> /dev/null; then + # use jattach so that Java processes in docker containers are also covered + # download jattach + curl -s -L -o /tmp/jattach https://github.com/apangin/jattach/releases/download/v2.1/jattach + if command -v sha256sum &> /dev/null; then + # verify hash of jattach binary + sha256sum -c <(echo "07885fdc782e02e7302c6d190f54c3930afa10a38140365adf54076ec1086a8e /tmp/jattach") || exit 1 + fi + chmod +x /tmp/jattach + for java_pid in $(sudo pgrep java); do + echo "----------------------- pid $java_pid -----------------------" + echo "command line: $(sudo cat /proc/$java_pid/cmdline | xargs -0 echo)" + sudo /tmp/jattach $java_pid jcmd VM.command_line || true + sudo /tmp/jattach $java_pid jcmd "Thread.print -l" + sudo /tmp/jattach $java_pid jcmd GC.heap_info || true + done + else + for java_pid in $(jps -q -J-XX:+PerfDisableSharedMem); do + echo "----------------------- pid $java_pid -----------------------" + jcmd $java_pid VM.command_line || true + jcmd $java_pid Thread.print -l + jcmd $java_pid GC.heap_info || true + done + fi + exit 0 + shell: bash \ No newline at end of file diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index 369ffeaf21e..255be73ebc3 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -73,6 +73,10 @@ jobs: - name: Checking bom dependency versions run: ./.github/scripts/check_bom_dependencies.sh + - name: print JVM thread dumps when cancelled + uses: ./.github/actions/thread-dump-jvms + if: cancelled() + - uses: actions/upload-artifact@v2 if: ${{ failure() }} with: diff --git a/.github/workflows/ci-pr.yml b/.github/workflows/ci-pr.yml index 64ca064d58a..4c2bc1c5799 100644 --- a/.github/workflows/ci-pr.yml +++ b/.github/workflows/ci-pr.yml @@ -49,6 +49,10 @@ jobs: - name: Checking bom dependency versions run: ./.github/scripts/check_bom_dependencies.sh + - name: print JVM thread dumps when cancelled + uses: ./.github/actions/thread-dump-jvms + if: cancelled() + build-pr-windows: runs-on: windows-2019 name: windows-x86_64-java11-boringssl @@ -73,6 +77,10 @@ jobs: - name: Build project run: ./mvnw.cmd -B -ntp --file pom.xml clean package -Pboringssl -DskipHttp2Testsuite=true -DskipAutobahnTestsuite=true + - name: print JVM thread dumps when cancelled + uses: ./.github/actions/thread-dump-jvms + if: cancelled() + - name: Upload Test Results if: always() uses: actions/upload-artifact@v2 @@ -193,6 +201,10 @@ jobs: - name: Checking for detected leak run: ./.github/scripts/check_leak.sh build-leak.output + - name: print JVM thread dumps when cancelled + uses: ./.github/actions/thread-dump-jvms + if: cancelled() + - name: Upload Test Results if: always() uses: actions/upload-artifact@v2 @@ -208,4 +220,4 @@ jobs: **/target/surefire-reports/ **/target/autobahntestsuite-reports/ **/hs_err*.log - **/core.* + **/core.* \ No newline at end of file