提交 ade2d2c3 authored 作者: Noel Grandin's avatar Noel Grandin

issue 1350: TestCrashAPI: PageStore.freeListPagesPerList

this looks like some kind of race condition where we are attempting to compact a PageStore which has not been properly opened yet.
Various places in Database are touching the pageStore without being synchronized, so fix those and lets see if that helps
上级 d9a7cf0d
...@@ -549,13 +549,15 @@ public class Database implements DataHandler { ...@@ -549,13 +549,15 @@ public class Database implements DataHandler {
if (store != null) { if (store != null) {
store.closeImmediately(); store.closeImmediately();
} }
if (pageStore != null) { synchronized(this) {
try { if (pageStore != null) {
pageStore.close(); try {
} catch (DbException e) { pageStore.close();
// ignore } catch (DbException e) {
// ignore
}
pageStore = null;
} }
pageStore = null;
} }
if (lock != null) { if (lock != null) {
stopServer(); stopServer();
...@@ -2664,19 +2666,21 @@ public class Database implements DataHandler { ...@@ -2664,19 +2666,21 @@ public class Database implements DataHandler {
} }
return null; return null;
} }
if (pageStore == null) { synchronized (this) {
pageStore = new PageStore(this, databaseName + if (pageStore == null) {
Constants.SUFFIX_PAGE_FILE, accessModeData, cacheSize); pageStore = new PageStore(this, databaseName +
if (pageSize != Constants.DEFAULT_PAGE_SIZE) { Constants.SUFFIX_PAGE_FILE, accessModeData, cacheSize);
pageStore.setPageSize(pageSize); if (pageSize != Constants.DEFAULT_PAGE_SIZE) {
} pageStore.setPageSize(pageSize);
if (!readOnly && fileLockMethod == FileLockMethod.FS) { }
pageStore.setLockFile(true); if (!readOnly && fileLockMethod == FileLockMethod.FS) {
pageStore.setLockFile(true);
}
pageStore.setLogMode(logMode);
pageStore.open();
} }
pageStore.setLogMode(logMode); return pageStore;
pageStore.open();
} }
return pageStore;
} }
/** /**
...@@ -2925,28 +2929,33 @@ public class Database implements DataHandler { ...@@ -2925,28 +2929,33 @@ public class Database implements DataHandler {
if (log < 0 || log > 2) { if (log < 0 || log > 2) {
throw DbException.getInvalidValueException("LOG", log); throw DbException.getInvalidValueException("LOG", log);
} }
if (pageStore != null) {
if (log != PageStore.LOG_MODE_SYNC ||
pageStore.getLogMode() != PageStore.LOG_MODE_SYNC) {
// write the log mode in the trace file when enabling or
// disabling a dangerous mode
trace.error(null, "log {0}", log);
}
this.logMode = log;
pageStore.setLogMode(log);
}
if (store != null) { if (store != null) {
this.logMode = log; this.logMode = log;
return;
}
synchronized (this) {
if (pageStore != null) {
if (log != PageStore.LOG_MODE_SYNC ||
pageStore.getLogMode() != PageStore.LOG_MODE_SYNC) {
// write the log mode in the trace file when enabling or
// disabling a dangerous mode
trace.error(null, "log {0}", log);
}
this.logMode = log;
pageStore.setLogMode(log);
}
} }
} }
public int getLogMode() { public int getLogMode() {
if (pageStore != null) {
return pageStore.getLogMode();
}
if (store != null) { if (store != null) {
return logMode; return logMode;
} }
synchronized (this) {
if (pageStore != null) {
return pageStore.getLogMode();
}
}
return PageStore.LOG_MODE_OFF; return PageStore.LOG_MODE_OFF;
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论