提交 2525ce0b authored 作者: Andrei Tokar's avatar Andrei Tokar

MVTableEngine.close() - adjust parameter type to it's usage to avoid confusion

上级 ea8fd10f
...@@ -1519,16 +1519,18 @@ public class Database implements DataHandler { ...@@ -1519,16 +1519,18 @@ public class Database implements DataHandler {
} }
} }
reconnectModified(false); reconnectModified(false);
if (store != null && store.getMvStore() != null && !store.getMvStore().isClosed()) { if (store != null) {
long maxCompactTime = dbSettings.maxCompactTime; MVStore mvStore = store.getMvStore();
if (compactMode == CommandInterface.SHUTDOWN_COMPACT || if (mvStore != null && !mvStore.isClosed()) {
boolean compactFully =
compactMode == CommandInterface.SHUTDOWN_COMPACT ||
compactMode == CommandInterface.SHUTDOWN_DEFRAG || compactMode == CommandInterface.SHUTDOWN_DEFRAG ||
getSettings().defragAlways) { getSettings().defragAlways;
maxCompactTime = Long.MAX_VALUE; if (!compactFully && !mvStore.isReadOnly()) {
} else {
store.compactFile(dbSettings.maxCompactTime); store.compactFile(dbSettings.maxCompactTime);
} }
store.close(maxCompactTime); store.close(compactFully);
}
} }
if (systemSession != null) { if (systemSession != null) {
systemSession.close(); systemSession.close();
......
...@@ -360,19 +360,18 @@ public class MVTableEngine implements TableEngine { ...@@ -360,19 +360,18 @@ public class MVTableEngine implements TableEngine {
* fill rate are compacted, but old chunks are kept for some time, so * fill rate are compacted, but old chunks are kept for some time, so
* most likely the database file will not shrink. * most likely the database file will not shrink.
* *
* @param maxCompactTime the maximum time in milliseconds to compact * @param compactFully true if storage need to be compacted after closer
*/ */
public void close(long maxCompactTime) { public void close(boolean compactFully) {
try { try {
if (!mvStore.isClosed() && mvStore.getFileStore() != null) { FileStore fileStore = mvStore.getFileStore();
boolean compactFully = false; if (!mvStore.isClosed() && fileStore != null) {
if (!mvStore.getFileStore().isReadOnly()) { if (fileStore.isReadOnly()) {
compactFully = false;
} else {
transactionStore.close(); transactionStore.close();
if (maxCompactTime == Long.MAX_VALUE) {
compactFully = true;
}
} }
String fileName = mvStore.getFileStore().getFileName(); String fileName = fileStore.getFileName();
mvStore.close(); mvStore.close();
if (compactFully && FileUtils.exists(fileName)) { if (compactFully && FileUtils.exists(fileName)) {
// the file could have been deleted concurrently, // the file could have been deleted concurrently,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论