未验证 提交 75ad80cf 编写于 作者: H Haonan 提交者: GitHub

[IOTDB-811] fix upgrading mlog many times when upgrading system.properties crashed (#1543)

* fix upgrading mlog many times
Co-authored-by: NJialin Qiao <qjl16@mails.tsinghua.edu.cn>
Co-authored-by: NZesong Sun <szs19@mails.tsinghua.edu.cn>
上级 5a5b12a1
......@@ -191,6 +191,18 @@ public class IoTDBConfigCheck {
checkUnClosedTsFileV1();
MLogWriter.upgradeMLog(SCHEMA_DIR, MetadataConstant.METADATA_LOG);
upgradePropertiesFile();
// upgrade mlog finished, delete old mlog file
File mlogFile = SystemFileFactory.INSTANCE.getFile(SCHEMA_DIR + File.separator
+ MetadataConstant.METADATA_LOG);
File tmpMLogFile = SystemFileFactory.INSTANCE.getFile(mlogFile.getAbsolutePath()
+ ".tmp");
if (!mlogFile.delete()) {
throw new IOException("Deleting " + mlogFile + "failed.");
}
// rename tmpLogFile to mlog
FileUtils.moveFile(tmpMLogFile, mlogFile);
}
checkProperties();
}
......@@ -333,4 +345,3 @@ public class IoTDBConfigCheck {
}
......@@ -152,14 +152,6 @@ public class MLogWriter {
writer.flush();
}
}
// upgrade finished, delete old mlog file
if (!logFile.delete()) {
throw new IOException("Deleting " + logFile + "failed.");
}
// rename tmpLogFile to mlog
FSFactoryProducer.getFSFactory().moveFile(tmpLogFile, logFile);
}
public void clear() throws IOException {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册