提交 25386a28 authored 作者: Noel Grandin's avatar Noel Grandin

fix TestLinkedTable test in pagestore mode

上级 02b7615e
...@@ -20,7 +20,6 @@ import java.util.concurrent.ConcurrentHashMap; ...@@ -20,7 +20,6 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
import org.h2.api.DatabaseEventListener; import org.h2.api.DatabaseEventListener;
import org.h2.api.ErrorCode; import org.h2.api.ErrorCode;
import org.h2.api.JavaObjectSerializer; import org.h2.api.JavaObjectSerializer;
...@@ -94,6 +93,7 @@ public class Database implements DataHandler { ...@@ -94,6 +93,7 @@ public class Database implements DataHandler {
private static int initialPowerOffCount; private static int initialPowerOffCount;
private static final ThreadLocal<Session> META_LOCK_DEBUGGING = new ThreadLocal<>(); private static final ThreadLocal<Session> META_LOCK_DEBUGGING = new ThreadLocal<>();
private static final ThreadLocal<Database> META_LOCK_DEBUGGING_DB = new ThreadLocal<>();
private static final ThreadLocal<Throwable> META_LOCK_DEBUGGING_STACK = new ThreadLocal<>(); private static final ThreadLocal<Throwable> META_LOCK_DEBUGGING_STACK = new ThreadLocal<>();
/** /**
...@@ -211,6 +211,7 @@ public class Database implements DataHandler { ...@@ -211,6 +211,7 @@ public class Database implements DataHandler {
public Database(ConnectionInfo ci, String cipher) { public Database(ConnectionInfo ci, String cipher) {
META_LOCK_DEBUGGING.set(null); META_LOCK_DEBUGGING.set(null);
META_LOCK_DEBUGGING_DB.set(null);
META_LOCK_DEBUGGING_STACK.set(null); META_LOCK_DEBUGGING_STACK.set(null);
String name = ci.getName(); String name = ci.getName();
this.dbSettings = ci.getDbSettings(); this.dbSettings = ci.getDbSettings();
...@@ -932,17 +933,23 @@ public class Database implements DataHandler { ...@@ -932,17 +933,23 @@ public class Database implements DataHandler {
return true; return true;
} }
if (SysProperties.CHECK2) { if (SysProperties.CHECK2) {
final Session prev = META_LOCK_DEBUGGING.get(); // If we are locking two different databases in the same stack, just ignore it.
if (prev == null) { // This only happens in TestLinkedTable where we connect to another h2 DB in the same process.
META_LOCK_DEBUGGING.set(session); if (META_LOCK_DEBUGGING_DB.get() != null
META_LOCK_DEBUGGING_STACK.set(new Throwable("Last meta lock granted in this stack trace, "+ && META_LOCK_DEBUGGING_DB.get() != this) {
"this is debug information for following IllegalStateException")); final Session prev = META_LOCK_DEBUGGING.get();
} else if (prev != session) { if (prev == null) {
META_LOCK_DEBUGGING_STACK.get().printStackTrace(); META_LOCK_DEBUGGING.set(session);
throw new IllegalStateException("meta currently locked by " META_LOCK_DEBUGGING_DB.set(this);
+ prev +", sessionid="+ prev.getId() META_LOCK_DEBUGGING_STACK.set(new Throwable("Last meta lock granted in this stack trace, "+
+ " and trying to be locked by different session, " "this is debug information for following IllegalStateException"));
+ session +", sessionid="+ session.getId() + " on same thread"); } else if (prev != session) {
META_LOCK_DEBUGGING_STACK.get().printStackTrace();
throw new IllegalStateException("meta currently locked by "
+ prev +", sessionid="+ prev.getId()
+ " and trying to be locked by different session, "
+ session +", sessionid="+ session.getId() + " on same thread");
}
} }
} }
return meta.lock(session, true, true); return meta.lock(session, true, true);
...@@ -969,6 +976,7 @@ public class Database implements DataHandler { ...@@ -969,6 +976,7 @@ public class Database implements DataHandler {
if (SysProperties.CHECK2) { if (SysProperties.CHECK2) {
if (META_LOCK_DEBUGGING.get() == session) { if (META_LOCK_DEBUGGING.get() == session) {
META_LOCK_DEBUGGING.set(null); META_LOCK_DEBUGGING.set(null);
META_LOCK_DEBUGGING_DB.set(null);
META_LOCK_DEBUGGING_STACK.set(null); META_LOCK_DEBUGGING_STACK.set(null);
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论