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

New experimental system property "h2.modifyOnWrite".

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