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/17 03:36:41 UTC

[GitHub] [iotdb] MarcosZyk opened a new pull request, #5925: [IOTDB-3024] Implement SchemaRegion Memory mode snapshot

MarcosZyk opened a new pull request, #5925:
URL: https://github.com/apache/iotdb/pull/5925

   ## Description
   
   Implement snapshot feature for SchemaRegion Memory mode to speed up schemaRegion consensus group recovery
   
   


-- 
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


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

Posted by GitBox <gi...@apache.org>.
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


[GitHub] [iotdb] xingtanzjr merged pull request #5925: [IOTDB-3024] Implement SchemaRegion Memory mode snapshot

Posted by GitBox <gi...@apache.org>.
xingtanzjr merged PR #5925:
URL: https://github.com/apache/iotdb/pull/5925


-- 
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


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

Posted by GitBox <gi...@apache.org>.
MarcosZyk commented on code in PR #5925:
URL: https://github.com/apache/iotdb/pull/5925#discussion_r875535861


##########
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:
   I'm not sure whether the ```mLogSnapshot``` will be produced if the rename operation is failed. If not, the invoking is unnecessary. 



-- 
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