Browse Source

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().
rust-volume-server
Chris Lu 2 days ago
parent
commit
afe1877da8
  1. 6
      seaweed-volume/src/storage/erasure_coding/ec_volume.rs

6
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(())
}

Loading…
Cancel
Save