From afe1877da8609814cfa58fcbfd53deb9433abf97 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Tue, 17 Mar 2026 22:42:57 -0700 Subject: [PATCH] Flush .ecx in EC volume sync_to_disk matching Go's Sync() Go's EcVolume.Sync() flushes both the .ecj journal and the .ecx index to disk. The Rust version only flushed .ecj, leaving in-place deletion marks in .ecx unpersisted until close(). This could cause data inconsistency if the server crashes after marking a needle deleted in .ecx but before close(). --- seaweed-volume/src/storage/erasure_coding/ec_volume.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/seaweed-volume/src/storage/erasure_coding/ec_volume.rs b/seaweed-volume/src/storage/erasure_coding/ec_volume.rs index a746beca3..ff3973f20 100644 --- a/seaweed-volume/src/storage/erasure_coding/ec_volume.rs +++ b/seaweed-volume/src/storage/erasure_coding/ec_volume.rs @@ -178,11 +178,15 @@ impl EcVolume { format!("{}.ecj", self.idx_base_name()) } - /// Sync the EC volume's journal file to disk (matching Go's ecv.SyncToDisk()). + /// Sync the EC volume's journal and index files to disk (matching Go's ecv.Sync()). + /// Go flushes both .ecj and .ecx to ensure in-place deletion marks are persisted. pub fn sync_to_disk(&self) -> io::Result<()> { if let Some(ref ecj_file) = self.ecj_file { ecj_file.sync_all()?; } + if let Some(ref ecx_file) = self.ecx_file { + ecx_file.sync_all()?; + } Ok(()) }