diff --git a/storage/src/ordinal/storage.rs b/storage/src/ordinal/storage.rs index baa4cd26b1d..8146c2e35ea 100644 --- a/storage/src/ordinal/storage.rs +++ b/storage/src/ordinal/storage.rs @@ -371,14 +371,17 @@ impl> Ordinal { for section in sections_to_remove { if let Some(blob) = self.blobs.remove(§ion) { drop(blob); - self.context - .remove(&self.config.partition, Some(§ion.to_be_bytes())) - .await?; - // Remove the corresponding index range from intervals + // Remove from intervals before attempting disk removal so that + // if context.remove fails, blobs and intervals remain consistent. let start_index = section * items_per_blob; let end_index = (section + 1) * items_per_blob - 1; self.intervals.remove(start_index, end_index); + + self.context + .remove(&self.config.partition, Some(§ion.to_be_bytes())) + .await?; + debug!(section, start_index, end_index, "pruned blob"); }