From 32e89b877453bdd90492913ecdfc158e9e01560f Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Thu, 6 Aug 2026 15:37:40 -0700 Subject: [PATCH] rust: trim the new comments in the volume loader further --- seaweed-volume/src/storage/disk_location.rs | 17 ++++------------- seaweed-volume/src/storage/volume.rs | 10 ++++------ 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/seaweed-volume/src/storage/disk_location.rs b/seaweed-volume/src/storage/disk_location.rs index 1f10d7eb6..2c7221f96 100644 --- a/seaweed-volume/src/storage/disk_location.rs +++ b/seaweed-volume/src/storage/disk_location.rs @@ -122,8 +122,6 @@ impl DiskLocation { // Scan for .dat files let entries = fs::read_dir(&self.directory)?; let mut dat_files: Vec<(String, VolumeId)> = Vec::new(); - // Every collection claiming an id, in scan order; open_volumes keeps - // the first that opens. let mut to_load: Vec<(VolumeId, Vec)> = Vec::new(); let mut queued: HashMap = HashMap::new(); let mut seen = HashSet::new(); @@ -254,14 +252,9 @@ impl DiskLocation { Ok(()) } - /// Open the volumes the directory scan selected. Opening one is dominated - /// by reading its .idx into the needle map, so a disk holding thousands - /// takes thousands of serial index reads to come up; mirrors Go's - /// concurrentLoadingVolumes down to the max(cores, 10) worker count, whose - /// floor keeps a small-core box off one-at-a-time on IO-bound work. - /// - /// An id is only spoken for once a volume actually loads, so a corrupt - /// `colA_5.dat` still leaves `colB_5.dat` a chance. + /// Opening a volume is dominated by reading its .idx, so they load on + /// max(cores, 10) workers, as Go's concurrentLoadingVolumes does. An id is + /// only spoken for once one of its candidates opens. fn open_volumes( &self, to_load: Vec<(VolumeId, Vec)>, @@ -1549,8 +1542,7 @@ mod tests { assert!(ids.contains(&VolumeId(2))); } - // Two collections can name the same volume id on one disk; a candidate - // that fails to open must not shadow a good one behind it. + // Two collections can name the same volume id on one disk. #[test] fn test_open_volumes_falls_back_past_a_corrupt_candidate() { let tmp = TempDir::new().unwrap(); @@ -1579,7 +1571,6 @@ mod tests { loc.close(); } - // Same id under another collection, unopenable. let mut bad = vec![0u8; 16]; bad[0] = 9; // unsupported version std::fs::write(format!("{}/bad_9.dat", dir), &bad).unwrap(); diff --git a/seaweed-volume/src/storage/volume.rs b/seaweed-volume/src/storage/volume.rs index 67a03eef7..833cca1c1 100644 --- a/seaweed-volume/src/storage/volume.rs +++ b/seaweed-volume/src/storage/volume.rs @@ -1974,9 +1974,8 @@ impl Volume { /// Extra bytes mean an unindexed trailing record (a torn append); /// appending after one would place the next needle at an offset the /// 8-byte .idx encoding may not represent, so the volume is quarantined - /// read-only instead. Mirrors Go's verifyNeedleIntegrity, whose tail - /// check is v3-only -- a v1/v2 volume Go serves read-write must not go - /// read-only here. + /// read-only instead. Mirrors Go's verifyNeedleIntegrity, including its + /// v3-only tail check. fn verify_needle_integrity( &mut self, actual_offset: i64, @@ -4118,9 +4117,8 @@ mod tests { ); } - // Go's tail check is v3-only, so it serves a v1/v2 volume with an - // unindexed tail read-write. Checking it here flipped whole legacy disks - // read-only on their first boot under this server. + // Go's tail check is v3-only, so it serves a v1/v2 volume with an unindexed + // tail read-write; checking it here flipped whole legacy disks read-only. #[test] fn test_integrity_skips_dat_tail_check_before_v3() { let tmp = TempDir::new().unwrap();