提交 30107279 authored 作者: Thomas Mueller's avatar Thomas Mueller

There was a possible Java level deadlock when opening an uninitialized database…

There was a possible Java level deadlock when opening an uninitialized database and using a file system that also opened a database.
上级 69e02858
...@@ -53,7 +53,7 @@ public class Engine { ...@@ -53,7 +53,7 @@ public class Engine {
if (ifExists && !Database.exists(name)) { if (ifExists && !Database.exists(name)) {
throw DbException.get(ErrorCode.DATABASE_NOT_FOUND_1, name); throw DbException.get(ErrorCode.DATABASE_NOT_FOUND_1, name);
} }
database = new Database(name, ci, cipher); database = new Database(ci, cipher);
opened = true; opened = true;
if (database.getAllUsers().size() == 0) { if (database.getAllUsers().size() == 0) {
// users is the last thing we add, so if no user is around, // users is the last thing we add, so if no user is around,
...@@ -66,9 +66,14 @@ public class Engine { ...@@ -66,9 +66,14 @@ public class Engine {
if (!ci.isUnnamedInMemory()) { if (!ci.isUnnamedInMemory()) {
DATABASES.put(name, database); DATABASES.put(name, database);
} }
database.opened();
} }
synchronized (database) { synchronized (database) {
if (opened) {
// start the thread when already synchronizing on the database
// otherwise a deadlock can occur when the writer thread
// opens a new database (as in recovery testing)
database.opened();
}
if (database.isClosing()) { if (database.isClosing()) {
return null; return null;
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论