提交 a628610c authored 作者: noelgrandin's avatar noelgrandin

add AbbaLockingDetector to test process

上级 abac8a9d
...@@ -48,6 +48,11 @@ public class AbbaLockingDetector implements Runnable { ...@@ -48,6 +48,11 @@ public class AbbaLockingDetector implements Runnable {
return this; return this;
} }
public synchronized void reset() {
LOCK_ORDERING.clear();
KNOWN_DEADLOCKS.clear();
}
/** /**
* Stop collecting. * Stop collecting.
* *
...@@ -127,7 +132,7 @@ public class AbbaLockingDetector implements Runnable { ...@@ -127,7 +132,7 @@ public class AbbaLockingDetector implements Runnable {
} }
} }
private void markHigher(List<String> lockOrder, ThreadInfo threadInfo) { private synchronized void markHigher(List<String> lockOrder, ThreadInfo threadInfo) {
String topLock = lockOrder.get(lockOrder.size() - 1); String topLock = lockOrder.get(lockOrder.size() - 1);
Map<String, String> map = LOCK_ORDERING.get(topLock); Map<String, String> map = LOCK_ORDERING.get(topLock);
if (map == null) { if (map == null) {
...@@ -232,7 +237,7 @@ public class AbbaLockingDetector implements Runnable { ...@@ -232,7 +237,7 @@ public class AbbaLockingDetector implements Runnable {
} }
private static String getObjectName(MonitorInfo info) { private static String getObjectName(MonitorInfo info) {
return info.getClassName();// + "@" + info.getIdentityHashCode(); return info.getClassName() + "@" + Integer.toHexString(info.getIdentityHashCode());
} }
} }
...@@ -197,6 +197,7 @@ import org.h2.test.utils.OutputCatcher; ...@@ -197,6 +197,7 @@ import org.h2.test.utils.OutputCatcher;
import org.h2.test.utils.SelfDestructor; import org.h2.test.utils.SelfDestructor;
import org.h2.tools.DeleteDbFiles; import org.h2.tools.DeleteDbFiles;
import org.h2.tools.Server; import org.h2.tools.Server;
import org.h2.util.AbbaLockingDetector;
import org.h2.util.Profiler; import org.h2.util.Profiler;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
import org.h2.util.Utils; import org.h2.util.Utils;
...@@ -363,6 +364,8 @@ java org.h2.test.TestAll timer ...@@ -363,6 +364,8 @@ java org.h2.test.TestAll timer
private Server server; private Server server;
AbbaLockingDetector abbaLockingDetector;
/** /**
* Run all tests. * Run all tests.
* *
...@@ -509,6 +512,10 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1` ...@@ -509,6 +512,10 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
*/ */
private void runTests() throws SQLException { private void runTests() throws SQLException {
if (Boolean.getBoolean("abba")) {
abbaLockingDetector = new AbbaLockingDetector().startCollecting();
}
coverage = isCoverage(); coverage = isCoverage();
smallLog = big = networked = memory = ssl = false; smallLog = big = networked = memory = ssl = false;
......
...@@ -138,6 +138,9 @@ public abstract class TestBase { ...@@ -138,6 +138,9 @@ public abstract class TestBase {
* @param conf the test configuration * @param conf the test configuration
*/ */
public void runTest(TestAll conf) { public void runTest(TestAll conf) {
if (conf.abbaLockingDetector != null) {
conf.abbaLockingDetector.reset();
}
try { try {
init(conf); init(conf);
start = System.currentTimeMillis(); start = System.currentTimeMillis();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论