This is an automated email from the ASF dual-hosted git repository.

marklau99 pushed a commit to branch take-snapshot-for-mods-by-copy
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit eba538fd5a950abbed129ee707e0eaeaefde8f20
Author: Liu Xuxin <[email protected]>
AuthorDate: Fri Dec 15 14:53:04 2023 +0800

    take snapshot for mods using copy
---
 .../storageengine/dataregion/snapshot/SnapshotTaker.java   | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/snapshot/SnapshotTaker.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/snapshot/SnapshotTaker.java
index b404ca2fd5e..a9f43b34fd1 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/snapshot/SnapshotTaker.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/snapshot/SnapshotTaker.java
@@ -177,7 +177,7 @@ public class SnapshotTaker {
             new File(snapshotTsFile.getAbsolutePath() + 
TsFileResource.RESOURCE_SUFFIX),
             new File(tsFile.getAbsolutePath() + 
TsFileResource.RESOURCE_SUFFIX));
         if (resource.getModFile().exists()) {
-          createHardLink(
+          copyFile(
               new File(snapshotTsFile.getAbsolutePath() + 
ModificationFile.FILE_SUFFIX),
               new File(tsFile.getAbsolutePath() + 
ModificationFile.FILE_SUFFIX));
         }
@@ -201,6 +201,18 @@ public class SnapshotTaker {
     snapshotLogger.logFile(source);
   }
 
+  private void copyFile(File target, File source) throws IOException {
+    if (!target.getParentFile().exists()) {
+      LOGGER.error("Hard link target dir {} doesn't exist", 
target.getParentFile());
+    }
+    if (!source.exists()) {
+      LOGGER.error("Hard link source file {} doesn't exist", source);
+    }
+    Files.deleteIfExists(target.toPath());
+    Files.copy(source.toPath(), target.toPath());
+    snapshotLogger.logFile(source);
+  }
+
   /**
    * Construct the snapshot file path for a given tsfile, and will create the 
dir. Eg, given a
    * tsfile in /data/iotdb/data/sequence/root.testsg/1/0/1-1-0-0.tsfile, with 
snapshotId "sm123",

Reply via email to