Package org.h2.util
Class AbbaLockingDetector
java.lang.Object
org.h2.util.AbbaLockingDetector
- All Implemented Interfaces:
Runnable
Utility to detect AB-BA deadlocks.
-
Field Summary
FieldsModifier and TypeFieldDescriptionMap of (object A) -> ( map of (object locked before object A) -> (stack trace where locked) )private boolean
private Thread
private final ThreadMXBean
private final int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static void
dumpStackTraceElement
(ThreadInfo info, StringBuilder sb, int i, StackTraceElement e) private static void
generateOrdering
(List<String> lockOrder, ThreadInfo info) We cannot simply call getLockedMonitors because it is not guaranteed to return the locks in the correct order.private static String
getObjectName
(MonitorInfo info) private static String
Dump data in the same format asThreadInfo.toString()
, but with some modifications (no stack frame limit, and removal of uninteresting stack frames)private void
markHigher
(List<String> lockOrder, ThreadInfo threadInfo) private void
processThreadList
(ThreadInfo[] threadInfoList) void
reset()
Reset the state.void
run()
Start collecting locking data.Stop collecting.private void
tick()
-
Field Details
-
tickIntervalMs
private final int tickIntervalMs- See Also:
-
stop
private volatile boolean stop -
threadMXBean
-
thread
-
lockOrdering
Map of (object A) -> ( map of (object locked before object A) -> (stack trace where locked) ) -
knownDeadlocks
-
-
Constructor Details
-
AbbaLockingDetector
public AbbaLockingDetector()
-
-
Method Details
-
startCollecting
Start collecting locking data.- Returns:
- this
-
reset
public void reset()Reset the state. -
stopCollecting
Stop collecting.- Returns:
- this
-
run
public void run() -
tick
private void tick() -
processThreadList
-
generateOrdering
We cannot simply call getLockedMonitors because it is not guaranteed to return the locks in the correct order. -
markHigher
-
getStackTraceForThread
Dump data in the same format asThreadInfo.toString()
, but with some modifications (no stack frame limit, and removal of uninteresting stack frames) -
dumpStackTraceElement
private static void dumpStackTraceElement(ThreadInfo info, StringBuilder sb, int i, StackTraceElement e) -
getObjectName
-