Browse Source

fix: guard against nil needle map before compaction sync

Add an early check for None needle map in do_compact_by_index, matching
Go's defensive nil check (commit 889ae7d22). In Rust the store RwLock
prevents the concurrent vacuum race that Go fixes with atomic.Bool,
but the nil guard is still useful as defensive code.
rust-volume-server
Chris Lu 6 days ago
parent
commit
c527cfd8c7
  1. 8
      seaweed-volume/src/storage/volume.rs

8
seaweed-volume/src/storage/volume.rs

@ -1800,6 +1800,14 @@ impl Volume {
where
F: Fn(i64) -> bool,
{
// Guard against nil needle map (matches Go's nil check before compaction sync)
if self.nm.is_none() {
return Err(VolumeError::Io(io::Error::new(
io::ErrorKind::Other,
format!("volume {} needle map is nil", self.id),
)));
}
// Record state before compaction for makeupDiff
self.last_compact_index_offset = self.nm.as_ref().map_or(0, |nm| nm.index_file_size());
self.last_compact_revision = self.super_block.compaction_revision;

Loading…
Cancel
Save