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

tanxinyu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/master by this push:
     new 54a3733263f Take snapshot for mods using copy instead of hard link 
(#11728)
54a3733263f is described below

commit 54a3733263ffb70dd77e11264349331902a2f1d7
Author: Liu Xuxin <[email protected]>
AuthorDate: Fri Dec 15 17:08:56 2023 +0800

    Take snapshot for mods using copy instead of hard link (#11728)
---
 .../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..a107f237bde 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("Copy target dir {} doesn't exist", target.getParentFile());
+    }
+    if (!source.exists()) {
+      LOGGER.error("Copy 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