Deadlock Analysis with Thread Dumps - RealWorld-Yuchen-Yang/Notes GitHub Wiki

  • Thread Dump is a JVM technique to analysis Deadlock
  • A thread dump includes a stack trace for each running thread.
  • Thread dump also include locking information, such as
    • which locks are held by each thread
    • in which stack frame they were acquired,
    • which lock a blocked thread is waiting to acquire
  • Trigger a thread dump:
    • option1, send JVM process a SIGQUIT signal (kill -3)
    • press ctrl-\ key
    • request from IDE
  • Thread dump tools
    • OS native command kill -3 , Note: PID can be obtained from "ps -ef| grep java"
    • JDK jstack utility, jstack
    • Java Visual VM
    • Oracle WebLogic Admin Console
  • Thread dump analysis with Tomcat
    • issue "kill -3 <TOMCAT_PID>", the dump will appear in TOMCAT/logs/catalina.out
    • issue "jstack <TOMCAT_PID>", the dump will appear in the current console
  • You can generate thread dump several times, by comparing the dump sampling results, you can better analysis the behavior
  • Thread dump analysis
    • Java head utilization is very useful for correlation with thread problem patterns such as internal contention
    • differentiate healthy and non-healthy threads
      • healthy: a thread waiting for a task
      • non-healthy: a thread is executing a task for too long or STUCK
    • Primary thread dump analysis objective: identify one or many problem patterns
    • Always analysis thread stack trace from bottom up
    • thread lock contention: identify the culprit thread holding the FLAT LOCK
    • thread dump analysis exposing abnormal slowdown conditions, such as "logging", "class loading", "XML parsing", etc. is often the symptom of excessive JVM garbage collection, and/or Java Heap Depletion
    • When potential problems are identified by analyzing thread stack trace, go to the "Heap Section" to see the root cause of the dead lock
⚠️ **GitHub.com Fallback** ⚠️