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

New experimental system property "h2.modifyOnWrite".

上级 56466880
......@@ -543,13 +543,37 @@ public class Database implements DataHandler {
}
}
}
if (SysProperties.MODIFY_ON_WRITE) {
while (isReconnectNeeded()) {
// wait until others stopped writing
}
} else {
while (isReconnectNeeded() && !beforeWriting()) {
// wait until others stopped writing and
// until we can write (file are not open - no need to re-connect)
// until we can write (the file is not yet open -
// no need to re-connect)
}
}
deleteOldTempFiles();
starting = true;
if (SysProperties.MODIFY_ON_WRITE) {
try {
getPageStore();
} catch (DbException e) {
if (e.getErrorCode() != ErrorCode.DATABASE_IS_READ_ONLY) {
throw e;
}
pageStore = null;
while (!beforeWriting()) {
// wait until others stopped writing and
// until we can write (the file is not yet open -
// no need to re-connect)
}
getPageStore();
}
} else {
getPageStore();
}
starting = false;
writer = WriterThread.create(this, writeDelay);
} else {
......@@ -630,8 +654,10 @@ public class Database implements DataHandler {
getLobStorage().init();
systemSession.commit(true);
trace.info("opened {0}", databaseName);
if (checkpointAllowed > 0) {
afterWriting();
}
}
private void startServer(String key) {
try {
......@@ -1203,12 +1229,14 @@ public class Database implements DataHandler {
if (fileLockMethod == FileLock.LOCK_SERIALIZED) {
// wait before deleting the .lock file,
// otherwise other connections can not detect that
if (lock.load().containsKey("changePending")) {
try {
Thread.sleep((int) (reconnectCheckDelay * 1.1));
} catch (InterruptedException e) {
trace.error(e, "close");
}
}
}
lock.unlock();
lock = null;
}
......
......@@ -576,9 +576,14 @@ public class TestFileLockSerialized extends TestBase {
assertTrue(rs.next());
assertEquals(500, rs.getInt(1));
rs.close();
// wait until the task finished
importUpdate.get();
Thread.sleep(1000);
rs = stat.executeQuery("select id2 from test where id=500");
// can't use the exact same query, otherwise it would use
// the query cache
rs = stat.executeQuery("select id2 from test where id=500+0");
assertTrue(rs.next());
assertEquals(999, rs.getInt(1));
rs.close();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论