From 513d123145c4d01e01a53b1f321c2eed5c9d7edf Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Tue, 17 Mar 2026 14:41:03 -0700 Subject: [PATCH] Match Go delete_collection: skip volumes with compaction in progress Go checks !v.isCompactionInProgress.Load() before destroying a volume during collection deletion, skipping compacting volumes. Also changed destroy errors to log instead of aborting the entire collection delete. --- seaweed-volume/src/storage/disk_location.rs | 6 ++++-- seaweed-volume/src/storage/volume.rs | 5 +++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/seaweed-volume/src/storage/disk_location.rs b/seaweed-volume/src/storage/disk_location.rs index 3c706913b..e619bb82a 100644 --- a/seaweed-volume/src/storage/disk_location.rs +++ b/seaweed-volume/src/storage/disk_location.rs @@ -392,7 +392,7 @@ impl DiskLocation { let vids: Vec = self .volumes .iter() - .filter(|(_, v)| v.collection == collection) + .filter(|(_, v)| v.collection == collection && !v.is_compacting()) .map(|(vid, _)| *vid) .collect(); @@ -401,7 +401,9 @@ impl DiskLocation { crate::metrics::VOLUME_GAUGE .with_label_values(&[&v.collection, "volume"]) .dec(); - v.destroy(false)?; + if let Err(e) = v.destroy(false) { + warn!(volume_id = vid.0, error = %e, "delete collection: failed to destroy volume"); + } } } diff --git a/seaweed-volume/src/storage/volume.rs b/seaweed-volume/src/storage/volume.rs index aeaffdd7b..26bc69af9 100644 --- a/seaweed-volume/src/storage/volume.rs +++ b/seaweed-volume/src/storage/volume.rs @@ -556,6 +556,11 @@ impl Volume { Ok(v) } + /// Returns true if the volume is currently being compacted. + pub fn is_compacting(&self) -> bool { + self.is_compacting + } + // ---- File naming (matching Go) ---- /// Base filename: dir/collection_id or dir/id