From bd3a3080870878d678582d92b05e657b6db6996a Mon Sep 17 00:00:00 2001 From: liulx20 Date: Tue, 26 Dec 2023 10:33:09 +0800 Subject: [PATCH 1/2] fix copy --- flex/storages/rt_mutable_graph/file_names.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/flex/storages/rt_mutable_graph/file_names.h b/flex/storages/rt_mutable_graph/file_names.h index 4a2763bfbce0..a4d5e79026e5 100644 --- a/flex/storages/rt_mutable_graph/file_names.h +++ b/flex/storages/rt_mutable_graph/file_names.h @@ -98,6 +98,8 @@ inline void copy_file(const std::string& src, const std::string& dst) { LOG(ERROR) << "Failed to set read/write permission for file: " << dst << " " << errorCode.message() << std::endl; } + close(dst_fd); + dst_fd = open(dst.c_str(), O_WRONLY); } ssize_t ret; do { From a4e892c8ac87f2353150048b1cb7b0316346e1db Mon Sep 17 00:00:00 2001 From: liulx20 Date: Tue, 26 Dec 2023 12:57:05 +0800 Subject: [PATCH 2/2] add comment --- flex/storages/rt_mutable_graph/file_names.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/flex/storages/rt_mutable_graph/file_names.h b/flex/storages/rt_mutable_graph/file_names.h index a4d5e79026e5..7ffa6bbb365f 100644 --- a/flex/storages/rt_mutable_graph/file_names.h +++ b/flex/storages/rt_mutable_graph/file_names.h @@ -98,6 +98,11 @@ inline void copy_file(const std::string& src, const std::string& dst) { LOG(ERROR) << "Failed to set read/write permission for file: " << dst << " " << errorCode.message() << std::endl; } + + // For a newly created file, you may need to close and then reopen it, + // otherwise you may encounter a copy_file_range "Invalid cross-device link" + // error, one possible cause of the error could be that the + // file's metadata has not yet been flushed to the file system. close(dst_fd); dst_fd = open(dst.c_str(), O_WRONLY); }