提交 69f5efd2 authored 作者: Thomas Mueller's avatar Thomas Mueller

Server-less multi-connection mode: more bugs are fixed.

上级 51e494cd
...@@ -477,7 +477,7 @@ public class SysProperties { ...@@ -477,7 +477,7 @@ public class SysProperties {
* notify a change in the .lock.db file, then wait twice this many * notify a change in the .lock.db file, then wait twice this many
* milliseconds before updating the database. * milliseconds before updating the database.
*/ */
public static final int RECONNECT_CHECK_DELAY = getIntSetting("h2.reconnectCheckDelay", 100); public static final int RECONNECT_CHECK_DELAY = getIntSetting("h2.reconnectCheckDelay", 200);
/** /**
* System property <code>h2.redoBufferSize</code> (default: 262144).<br /> * System property <code>h2.redoBufferSize</code> (default: 262144).<br />
......
...@@ -165,8 +165,8 @@ public class Database implements DataHandler { ...@@ -165,8 +165,8 @@ public class Database implements DataHandler {
private PageStore pageStore; private PageStore pageStore;
private Properties reconnectLastLock; private Properties reconnectLastLock;
private long reconnectCheckNext; private volatile long reconnectCheckNext;
private boolean reconnectChangePending; private volatile boolean reconnectChangePending;
public Database(String name, ConnectionInfo ci, String cipher) throws SQLException { public Database(String name, ConnectionInfo ci, String cipher) throws SQLException {
this.compareMode = CompareMode.getInstance(null, 0); this.compareMode = CompareMode.getInstance(null, 0);
...@@ -344,6 +344,9 @@ public class Database implements DataHandler { ...@@ -344,6 +344,9 @@ public class Database implements DataHandler {
String pos = log == null ? null : log.getWritePos(); String pos = log == null ? null : log.getWritePos();
lock.setProperty("logPos", pos); lock.setProperty("logPos", pos);
lock.setProperty("changePending", pending ? "true" : null); lock.setProperty("changePending", pending ? "true" : null);
// ensure that the writer thread will
// not reset the flag before we are done
reconnectCheckNext = System.currentTimeMillis() + 2 * SysProperties.RECONNECT_CHECK_DELAY;
old = lock.save(); old = lock.save();
if (pending) { if (pending) {
...@@ -1802,6 +1805,14 @@ public class Database implements DataHandler { ...@@ -1802,6 +1805,14 @@ public class Database implements DataHandler {
* @param fileName the name of the file to be deleted * @param fileName the name of the file to be deleted
*/ */
public void deleteLogFileLater(String fileName) throws SQLException { public void deleteLogFileLater(String fileName) throws SQLException {
if (fileLockMethod == FileLock.LOCK_SERIALIZED) {
// need to truncate the file, because another process could keep it open
try {
FileSystem.getInstance(fileName).openFileObject(fileName, "rw").setFileLength(0);
} catch (IOException e) {
throw Message.convertIOException(e, "could not truncate " + fileName);
}
}
if (writer != null) { if (writer != null) {
writer.deleteLogFileLater(fileName); writer.deleteLogFileLater(fileName);
} else { } else {
...@@ -2289,6 +2300,7 @@ public class Database implements DataHandler { ...@@ -2289,6 +2300,7 @@ public class Database implements DataHandler {
if (fileLockMethod != FileLock.LOCK_SERIALIZED || readOnly || !reconnectChangePending || closing) { if (fileLockMethod != FileLock.LOCK_SERIALIZED || readOnly || !reconnectChangePending || closing) {
return; return;
} }
synchronized (this) {
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
if (now > reconnectCheckNext + SysProperties.RECONNECT_CHECK_DELAY) { if (now > reconnectCheckNext + SysProperties.RECONNECT_CHECK_DELAY) {
getTrace().debug("checkpoint"); getTrace().debug("checkpoint");
...@@ -2297,6 +2309,7 @@ public class Database implements DataHandler { ...@@ -2297,6 +2309,7 @@ public class Database implements DataHandler {
reconnectModified(false); reconnectModified(false);
} }
} }
}
/** /**
* Flush the indexes that were last changed prior to some time. * Flush the indexes that were last changed prior to some time.
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论