Browse Source

Match Go NeedleMap.Delete: use !is_deleted() instead of is_valid()

Go's CompactMap.Delete checks !IsDeleted() not IsValid(), so needles
with size==0 (live but anomalous) can still be deleted. The Rust code
was using is_valid() which returns false for size==0, preventing
deletion of such needles.
rust-volume-server
Chris Lu 3 days ago
parent
commit
6b4bb30d3c
  1. 4
      seaweed-volume/src/storage/needle_map.rs

4
seaweed-volume/src/storage/needle_map.rs

@ -204,9 +204,11 @@ impl CompactNeedleMap {
}
/// Mark a needle as deleted. Appends tombstone to .idx file.
/// Matches Go's CompactMap.Delete: checks !IsDeleted() (not IsValid()),
/// so needles with size==0 can still be deleted.
pub fn delete(&mut self, key: NeedleId, offset: Offset) -> io::Result<Option<Size>> {
if let Some(old) = self.map.get(key) {
if old.size.is_valid() {
if !old.size.is_deleted() {
// Persist tombstone to idx file BEFORE mutating in-memory state for crash consistency
if let Some(ref mut idx_file) = self.idx_file {
idx::write_index_entry(idx_file, key, offset, TOMBSTONE_FILE_SIZE)?;

Loading…
Cancel
Save