You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2022/05/18 06:58:45 UTC

[GitHub] [iotdb] xingtanzjr commented on a diff in pull request #5925: [IOTDB-3024] Implement SchemaRegion Memory mode snapshot

xingtanzjr commented on code in PR #5925:
URL: https://github.com/apache/iotdb/pull/5925#discussion_r875533611


##########
server/src/main/java/org/apache/iotdb/db/metadata/schemaregion/SchemaRegionMemoryImpl.java:
##########
@@ -409,6 +413,72 @@ public synchronized void deleteSchemaRegion() throws MetadataException {
     SchemaRegionUtils.deleteSchemaRegionFolder(schemaRegionDirPath, logger);
   }
 
+  @Override
+  public synchronized boolean createSnapshot(File snapshotDir) {
+    File mLogSnapshotTmp =
+        SystemFileFactory.INSTANCE.getFile(snapshotDir, MetadataConstant.METADATA_LOG_SNAPSHOT_TMP);
+    File mLogSnapshot =
+        SystemFileFactory.INSTANCE.getFile(snapshotDir, MetadataConstant.METADATA_LOG_SNAPSHOT);
+
+    try {
+      logWriter.copyTo(mLogSnapshotTmp);
+      mLogSnapshot.delete();
+      if (!mLogSnapshotTmp.renameTo(mLogSnapshot)) {
+        logger.error(
+            "Failed to rename {} to {} while creating snapshot for schemaRegion {}.",
+            mLogSnapshotTmp.getName(),
+            mLogSnapshot.getName(),
+            schemaRegionId);
+        mLogSnapshot.delete();

Review Comment:
   Why is `delete()` invoked again here ?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org