提交 90b7019c authored 作者: Noel Grandin's avatar Noel Grandin

fix for watchdog

上级 b49019f1
...@@ -16,6 +16,7 @@ import java.util.ArrayList; ...@@ -16,6 +16,7 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Timer; import java.util.Timer;
import java.util.TimerTask; import java.util.TimerTask;
import org.h2.engine.SysProperties;
import org.h2.mvstore.db.MVTable; import org.h2.mvstore.db.MVTable;
/** /**
...@@ -73,19 +74,31 @@ public class ThreadDeadlockDetector { ...@@ -73,19 +74,31 @@ public class ThreadDeadlockDetector {
dumpThreadsAndLocks(msg, threadBean, allThreadIds); dumpThreadsAndLocks(msg, threadBean, allThreadIds);
} }
private static void dumpThreadsAndLocks(String msg, ThreadMXBean threadBean, long[] threadIds) private static void dumpThreadsAndLocks(String msg, ThreadMXBean threadBean,
{ long[] threadIds) {
final StringWriter stringWriter = new StringWriter(); final StringWriter stringWriter = new StringWriter();
final PrintWriter print = new PrintWriter(stringWriter); final PrintWriter print = new PrintWriter(stringWriter);
print.println(msg); print.println(msg);
final ThreadInfo[] infos = threadBean.getThreadInfo(threadIds, true, true);
final HashMap<Long, String> tableWaitingForLockMap = final HashMap<Long, String> tableWaitingForLockMap;
MVTable.WAITING_FOR_LOCK.getSnapshotOfAllThreads(); final HashMap<Long, ArrayList<String>> tableExclusiveLocksMap;
final HashMap<Long, ArrayList<String>> tableExclusiveLocksMap = final HashMap<Long, ArrayList<String>> tableSharedLocksMap;
MVTable.EXCLUSIVE_LOCKS.getSnapshotOfAllThreads(); if (SysProperties.THREAD_DEADLOCK_DETECTOR) {
final HashMap<Long, ArrayList<String>> tableSharedLocksMap = tableWaitingForLockMap = MVTable.WAITING_FOR_LOCK
MVTable.SHARED_LOCKS.getSnapshotOfAllThreads(); .getSnapshotOfAllThreads();
tableExclusiveLocksMap = MVTable.EXCLUSIVE_LOCKS
.getSnapshotOfAllThreads();
tableSharedLocksMap = MVTable.SHARED_LOCKS
.getSnapshotOfAllThreads();
} else {
tableWaitingForLockMap = New.hashMap();
tableExclusiveLocksMap = New.hashMap();
tableSharedLocksMap = New.hashMap();
}
final ThreadInfo[] infos = threadBean.getThreadInfo(threadIds, true,
true);
for (ThreadInfo ti : infos) { for (ThreadInfo ti : infos) {
printThreadInfo(print, ti); printThreadInfo(print, ti);
printLockInfo(print, ti.getLockedSynchronizers(), printLockInfo(print, ti.getLockedSynchronizers(),
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论