提交 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()) {
compactMode == CommandInterface.SHUTDOWN_DEFRAG || boolean compactFully =
getSettings().defragAlways) { compactMode == CommandInterface.SHUTDOWN_COMPACT ||
maxCompactTime = Long.MAX_VALUE; compactMode == CommandInterface.SHUTDOWN_DEFRAG ||
} else { getSettings().defragAlways;
store.compactFile(dbSettings.maxCompactTime); if (!compactFully && !mvStore.isReadOnly()) {
store.compactFile(dbSettings.maxCompactTime);
}
store.close(compactFully);
} }
store.close(maxCompactTime);
} }
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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论