diff --git a/libs/utils/src/exp_counter.rs b/libs/utils/src/exp_counter.rs index 566ce2c3d3..17ab91cf46 100644 --- a/libs/utils/src/exp_counter.rs +++ b/libs/utils/src/exp_counter.rs @@ -23,6 +23,7 @@ pub struct ExpCounter { } impl ExpCounter { + /// Creates a new `ExpCounter` instance that counts to the (exclusive) maximum pub fn with_max(max: u64) -> Self { Self { max, diff --git a/pageserver/src/pgdatadir_mapping.rs b/pageserver/src/pgdatadir_mapping.rs index 89739b4e49..556d05b839 100644 --- a/pageserver/src/pgdatadir_mapping.rs +++ b/pageserver/src/pgdatadir_mapping.rs @@ -343,7 +343,7 @@ impl Timeline { let mut found_larger = false; // This is a search budget to not make the search too expensive - let mut budget = 10_000u16; + let mut budget = 1_000_000u32; while low < high { // cannot overflow, high and low are both smaller than u64::MAX / 2 // this always holds: low <= mid_start < high @@ -380,17 +380,17 @@ impl Timeline { if let Some(max) = max { if max <= search_timestamp { - found_smaller = true; // We found a commit with timestamp before (or at) `search_timestamp`. - // set low to mid + 1 + found_smaller = true; low = mid + 1; } else { + // We found a commit with timestamp after `search_timestamp`. found_larger = true; high = mid; } } else { // max is None so we have proof of a chain of None's from mid_start all up to high. - // Thus we can safely set high to mid + // Thus we can safely set high to mid_start high = mid_start; } }