diff --git a/pageserver/src/branches.rs b/pageserver/src/branches.rs index e9280f3de7..246d012e8d 100644 --- a/pageserver/src/branches.rs +++ b/pageserver/src/branches.rs @@ -242,9 +242,9 @@ fn bootstrap_timeline( // Because we know it upfront avoid having an option or dummy zero value by passing it to create_empty_timeline. let timeline = repo.create_empty_timeline(tli, lsn)?; - let page_tline: DatadirTimeline = DatadirTimeline::new(timeline); + let mut page_tline: DatadirTimeline = DatadirTimeline::new(timeline); - import_datadir::import_timeline_from_postgres_datadir(&pgdata_path, &page_tline, lsn)?; + import_datadir::import_timeline_from_postgres_datadir(&pgdata_path, &mut page_tline, lsn)?; page_tline.tline.checkpoint(CheckpointConfig::Forced)?; println!( diff --git a/pageserver/src/import_datadir.rs b/pageserver/src/import_datadir.rs index 5653c9a7ad..e2c646ae2a 100644 --- a/pageserver/src/import_datadir.rs +++ b/pageserver/src/import_datadir.rs @@ -30,7 +30,7 @@ use zenith_utils::lsn::Lsn; /// cluster was not shut down cleanly. pub fn import_timeline_from_postgres_datadir( path: &Path, - tline: &DatadirTimeline, + tline: &mut DatadirTimeline, lsn: Lsn, ) -> Result<()> { let mut pg_control: Option = None; @@ -335,7 +335,7 @@ fn import_slru_file( /// 'startpoint' and 'endpoint' into the repository. fn import_wal( walpath: &Path, - tline: &DatadirTimeline, + tline: &mut DatadirTimeline, startpoint: Lsn, endpoint: Lsn, ) -> Result<()> { diff --git a/pageserver/src/layered_repository.rs b/pageserver/src/layered_repository.rs index cd1b723651..35a864f2a6 100644 --- a/pageserver/src/layered_repository.rs +++ b/pageserver/src/layered_repository.rs @@ -1028,10 +1028,11 @@ impl LayeredTimeline { if prev_lsn <= cont_lsn { // Didn't make any progress in last iteration. Error out to avoid // getting stuck in the loop. - bail!("could not find layer with more data for key {} at LSN {}, request LSN {}", + bail!("could not find layer with more data for key {} at LSN {}, request LSN {}, ancestor {}", key, Lsn(cont_lsn.0 - 1), - request_lsn) + request_lsn, + timeline.ancestor_lsn) } prev_lsn = cont_lsn; } @@ -1047,7 +1048,7 @@ impl LayeredTimeline { // Recurse into ancestor if needed if Lsn(cont_lsn.0 - 1) <= timeline.ancestor_lsn { - //info!("going into ancestor {}", timeline.ancestor_lsn); + info!("going into ancestor {}, cont_lsn is {}", timeline.ancestor_lsn, cont_lsn); let ancestor = timeline.get_ancestor_timeline()?; timeline_owned = ancestor; timeline = &*timeline_owned; @@ -1060,7 +1061,7 @@ impl LayeredTimeline { // Check the open and frozen in-memory layers first if let Some(open_layer) = &layers.open_layer { let start_lsn = open_layer.get_lsn_range().start; - if cont_lsn >= start_lsn { + if cont_lsn > start_lsn { //info!("CHECKING for {} at {} on open layer {}", reconstruct_state.key, reconstruct_state.lsn, open_layer.filename().display()); result = open_layer.get_value_reconstruct_data(key, open_layer.get_lsn_range().start..cont_lsn, reconstruct_state)?; cont_lsn = open_layer.get_lsn_range().start; @@ -1069,7 +1070,7 @@ impl LayeredTimeline { } if let Some(frozen_layer) = &layers.frozen_layer { let start_lsn = frozen_layer.get_lsn_range().start; - if cont_lsn >= start_lsn { + if cont_lsn > start_lsn { //info!("CHECKING for {} at {} on frozen layer {}", reconstruct_state.key, reconstruct_state.lsn, frozen_layer.filename().display()); result = frozen_layer.get_value_reconstruct_data(key, frozen_layer.get_lsn_range().start..cont_lsn, reconstruct_state)?; cont_lsn = frozen_layer.get_lsn_range().start; @@ -1594,6 +1595,9 @@ impl LayeredTimeline { fn gc(&self) -> Result { let now = Instant::now(); let mut result: GcResult = Default::default(); + if true { + return Ok(result); + } let disk_consistent_lsn = self.get_disk_consistent_lsn(); let _checkpoint_cs = self.checkpoint_cs.lock().unwrap(); diff --git a/pageserver/src/pgdatadir_mapping.rs b/pageserver/src/pgdatadir_mapping.rs index 1c1f37ef82..fd586495dc 100644 --- a/pageserver/src/pgdatadir_mapping.rs +++ b/pageserver/src/pgdatadir_mapping.rs @@ -22,6 +22,7 @@ use std::sync::{Arc, RwLockReadGuard}; use tracing::{debug, info, warn}; use zenith_utils::bin_ser::BeSer; use zenith_utils::lsn::{Lsn, RecordLsn}; +use zenith_utils::lsn::AtomicLsn; /// Block number within a relation or SRU. This matches PostgreSQL's BlockNumber type. pub type BlockNumber = u32; @@ -31,7 +32,7 @@ where R: Repository, { pub tline: Arc, - pub last_partitioning: Option, + pub last_partitioning: AtomicLsn, } #[derive(Debug, Serialize, Deserialize)] @@ -71,7 +72,7 @@ impl DatadirTimeline { pub fn new(tline: Arc) -> Self { DatadirTimeline { tline, - last_partitioning: None, + last_partitioning: AtomicLsn::new(0), } } @@ -692,7 +693,7 @@ impl<'a, R: Repository> DatadirTimelineWriter<'a, R> { pub fn finish(self) -> Result<()> { let writer = self.tline.tline.writer(); - let last_partitioning = self.last_partitioning.unwrap_or(Lsn(0)); + let last_partitioning = self.last_partitioning.load(); for (key, value) in self.pending_updates { writer.put(key, self.lsn, value)?; @@ -707,6 +708,7 @@ impl<'a, R: Repository> DatadirTimelineWriter<'a, R> { let mut partitioning = self.tline.collect_keyspace(self.lsn)?; partitioning.repartition(TARGET_FILE_SIZE_BYTES); self.tline.tline.hint_partitioning(partitioning)?; + self.tline.last_partitioning.store(self.lsn); } Ok(()) diff --git a/pageserver/src/walreceiver.rs b/pageserver/src/walreceiver.rs index fd318b9cb7..17771d0151 100644 --- a/pageserver/src/walreceiver.rs +++ b/pageserver/src/walreceiver.rs @@ -242,7 +242,7 @@ fn walreceiver_main( let startlsn = Lsn::from(xlog_data.wal_start()); let endlsn = startlsn + data.len() as u64; - trace!("received XLogData between {} and {}", startlsn, endlsn); + info!("received XLogData between {} and {}", startlsn, endlsn); waldecoder.feed_bytes(data);