From ff83b808c879db48b85cd491f98559718a876272 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Tue, 17 Mar 2026 14:38:21 -0700 Subject: [PATCH] Match Go CopyFile: sync EC volume journal to disk before copying Go calls ecVolume.Sync() before copying EC volume files to ensure the .ecj journal is flushed to disk. Added sync_to_disk() to EcVolume and call it in the CopyFile EC branch. --- seaweed-volume/src/server/grpc_server.rs | 8 ++++++++ seaweed-volume/src/storage/erasure_coding/ec_volume.rs | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/seaweed-volume/src/server/grpc_server.rs b/seaweed-volume/src/server/grpc_server.rs index f55f10e37..786745681 100644 --- a/seaweed-volume/src/server/grpc_server.rs +++ b/seaweed-volume/src/server/grpc_server.rs @@ -1215,6 +1215,14 @@ impl VolumeServer for VolumeGrpcService { file_name = v.file_name(&req.ext); drop(store); } else { + // Sync EC volume journal to disk before copying (matching Go's ecv.SyncToDisk()) + { + let store = self.state.store.read().unwrap(); + if let Some(ecv) = store.find_ec_volume(vid) { + let _ = ecv.sync_to_disk(); + } + } + // EC volume: search disk locations for the file let store = self.state.store.read().unwrap(); let mut found_path = None; diff --git a/seaweed-volume/src/storage/erasure_coding/ec_volume.rs b/seaweed-volume/src/storage/erasure_coding/ec_volume.rs index 838f1b080..348a9c239 100644 --- a/seaweed-volume/src/storage/erasure_coding/ec_volume.rs +++ b/seaweed-volume/src/storage/erasure_coding/ec_volume.rs @@ -169,6 +169,14 @@ impl EcVolume { format!("{}.ecj", self.idx_base_name()) } + /// Sync the EC volume's journal file to disk (matching Go's ecv.SyncToDisk()). + pub fn sync_to_disk(&self) -> io::Result<()> { + if let Some(ref ecj_file) = self.ecj_file { + ecj_file.sync_all()?; + } + Ok(()) + } + // ---- Shard management ---- /// Add a shard to this volume.