mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-08-25 00:27:11 +00:00
rust: trim the new comments in the volume loader further
This commit is contained in:
@@ -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<String>)> = Vec::new();
|
||||
let mut queued: HashMap<VolumeId, usize> = 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<String>)>,
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user