Browse Source

Add CompactMapSegment overflow panic guard matching Go

rust-volume-server
Chris Lu 3 days ago
parent
commit
d94be89a60
  1. 8
      seaweed-volume/src/storage/needle_map/compact_map.rs

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

@ -114,6 +114,14 @@ impl Segment {
size,
};
// Match Go panic: don't exceed segment capacity
if self.list.len() >= SEGMENT_CHUNK_SIZE as usize {
panic!(
"attempted to write more than {} entries on CompactMapSegment",
SEGMENT_CHUNK_SIZE
);
}
if self.list.len() == SEGMENT_CHUNK_SIZE as usize - 1 {
// Pin capacity to exact size when maxing out
let mut new_list = Vec::with_capacity(SEGMENT_CHUNK_SIZE as usize);

Loading…
Cancel
Save