From 5df21e10582b25d18bfa0fce621dc2a186b0999a Mon Sep 17 00:00:00 2001 From: Dmitry Rodionov Date: Tue, 25 Jan 2022 20:27:10 +0300 Subject: [PATCH] remove Timeline::start_lsn in favor of ancestor_lsn --- pageserver/src/branches.rs | 7 ++++--- pageserver/src/http/routes.rs | 2 -- pageserver/src/layered_repository.rs | 10 +--------- pageserver/src/repository.rs | 4 +++- 4 files changed, 8 insertions(+), 15 deletions(-) diff --git a/pageserver/src/branches.rs b/pageserver/src/branches.rs index 662050018b..8a411060de 100644 --- a/pageserver/src/branches.rs +++ b/pageserver/src/branches.rs @@ -324,12 +324,13 @@ pub(crate) fn create_branch( timeline.wait_lsn(startpoint.lsn)?; } startpoint.lsn = startpoint.lsn.align(); - if timeline.get_start_lsn() > startpoint.lsn { + if timeline.get_ancestor_lsn() > startpoint.lsn { + // can we safely just branch from the ancestor instead? anyhow::bail!( - "invalid startpoint {} for the branch {}: less than timeline start {}", + "invalid startpoint {} for the branch {}: less than timeline ancestor lsn {:?}", startpoint.lsn, branchname, - timeline.get_start_lsn() + timeline.get_ancestor_lsn() ); } diff --git a/pageserver/src/http/routes.rs b/pageserver/src/http/routes.rs index 70308532d5..fedcb76609 100644 --- a/pageserver/src/http/routes.rs +++ b/pageserver/src/http/routes.rs @@ -202,7 +202,6 @@ enum TimelineInfo { ancestor_timeline_id: Option, last_record_lsn: Lsn, prev_record_lsn: Lsn, - start_lsn: Lsn, disk_consistent_lsn: Lsn, timeline_state: Option, }, @@ -237,7 +236,6 @@ async fn timeline_detail_handler(request: Request) -> Result = BTreeSet::new(); for &timelineid in &timelineids { let timeline = match self.get_or_init_timeline(timelineid, &mut timelines)? { @@ -1037,14 +1037,6 @@ impl Timeline for LayeredTimeline { self.last_record_lsn.load() } - fn get_start_lsn(&self) -> Lsn { - self.ancestor_timeline - .as_ref() - .and_then(|ancestor_entry| ancestor_entry.local_or_schedule_download(self.tenantid)) - .map(Timeline::get_start_lsn) - .unwrap_or(self.ancestor_lsn) - } - fn get_current_logical_size(&self) -> usize { self.current_logical_size.load(atomic::Ordering::Acquire) as usize } diff --git a/pageserver/src/repository.rs b/pageserver/src/repository.rs index 94eadcb7a4..d5cc9f4a3a 100644 --- a/pageserver/src/repository.rs +++ b/pageserver/src/repository.rs @@ -220,10 +220,12 @@ pub trait Timeline: Send + Sync { /// Atomically get both last and prev. fn get_last_record_rlsn(&self) -> RecordLsn; + /// Get last or prev record separately. Same as get_last_record_rlsn().last/prev. fn get_last_record_lsn(&self) -> Lsn; + fn get_prev_record_lsn(&self) -> Lsn; - fn get_start_lsn(&self) -> Lsn; + fn get_disk_consistent_lsn(&self) -> Lsn; /// Mutate the timeline with a [`TimelineWriter`].