diff --git a/seaweed-volume/src/storage/disk_location.rs b/seaweed-volume/src/storage/disk_location.rs index 352484fbe..e8d84b961 100644 --- a/seaweed-volume/src/storage/disk_location.rs +++ b/seaweed-volume/src/storage/disk_location.rs @@ -388,7 +388,7 @@ impl DiskLocation { } /// Delete all volumes in a collection. - pub fn delete_collection(&mut self, collection: &str) { + pub fn delete_collection(&mut self, collection: &str) -> Result<(), VolumeError> { let vids: Vec = self .volumes .iter() @@ -401,7 +401,7 @@ impl DiskLocation { crate::metrics::VOLUME_GAUGE .with_label_values(&[&v.collection, "volume"]) .dec(); - let _ = v.destroy(); + v.destroy()?; } } @@ -422,6 +422,7 @@ impl DiskLocation { ec_vol.destroy(); } } + Ok(()) } // ---- Metrics ---- @@ -871,7 +872,7 @@ mod tests { .unwrap(); assert_eq!(loc.volumes_len(), 3); - loc.delete_collection("pics"); + loc.delete_collection("pics").unwrap(); assert_eq!(loc.volumes_len(), 1); assert!(loc.find_volume(VolumeId(3)).is_some()); } @@ -898,7 +899,7 @@ mod tests { assert!(std::path::Path::new(&shard_path).exists()); assert!(std::path::Path::new(&format!("{}/pics_7.ecj", dir)).exists()); - loc.delete_collection("pics"); + loc.delete_collection("pics").unwrap(); assert!(!loc.has_ec_volume(VolumeId(7))); assert!(!std::path::Path::new(&shard_path).exists()); diff --git a/seaweed-volume/src/storage/store.rs b/seaweed-volume/src/storage/store.rs index f679df02f..47b65c747 100644 --- a/seaweed-volume/src/storage/store.rs +++ b/seaweed-volume/src/storage/store.rs @@ -373,11 +373,13 @@ impl Store { // ---- Collection operations ---- /// Delete all volumes in a collection. - pub fn delete_collection(&mut self, collection: &str) { + pub fn delete_collection(&mut self, collection: &str) -> Result<(), String> { for loc in &mut self.locations { - loc.delete_collection(collection); + loc.delete_collection(collection) + .map_err(|e| format!("delete collection {}: {}", collection, e))?; } crate::metrics::delete_collection_metrics(collection); + Ok(()) } // ---- Metrics ---- @@ -987,7 +989,7 @@ mod tests { .unwrap(); assert_eq!(store.total_volume_count(), 3); - store.delete_collection("pics"); + store.delete_collection("pics").unwrap(); assert_eq!(store.total_volume_count(), 1); assert!(store.has_volume(VolumeId(3))); }