diff --git a/pageserver/src/object_repository.rs b/pageserver/src/object_repository.rs index 3b68102624..a8148a3de9 100644 --- a/pageserver/src/object_repository.rs +++ b/pageserver/src/object_repository.rs @@ -272,20 +272,22 @@ impl Timeline for ObjectTimeline { ); } - // Handle truncated SLRU segments. + // Handle truncated non-rel relishes + // We should never return a stale or zeroed page for the truncated SLRU segment. // XXX if this will turn out to be performance critical, // move this check out of the funciton. - if let RelishTag::Slru { - slru: _slru, - segno: _segno, - } = rel - { - info!("test SLRU rel {:?} at {}", rel, req_lsn); - if !self.get_rel_exists(rel, req_lsn).unwrap_or(false) { - info!("SLRU rel {:?} at {} doesn't exist", rel, req_lsn); - return Err(anyhow!("SLRU rel doesn't exist")); - } - } + // + match rel { + RelishTag::Slru { .. } | + RelishTag::TwoPhase{ .. } => + { + if !self.get_rel_exists(rel, req_lsn).unwrap_or(false) { + trace!("{:?} at {} doesn't exist", rel, req_lsn); + return Err(anyhow!("non-rel relish doesn't exist")); + } + }, + _ => () + }; const ZERO_PAGE: [u8; 8192] = [0u8; 8192]; // Look up the page entry. If it's a page image, return that. If it's a WAL record, @@ -341,9 +343,9 @@ impl Timeline for ObjectTimeline { /// Get size of a relish in number of blocks /// Return None if the relish was truncated fn get_relish_size(&self, rel: RelishTag, lsn: Lsn) -> Result> { - if !rel.is_blocky() { + if !rel.is_physical() { bail!( - "invalid get_relish_size request for non-blocky relish {}", + "invalid get_relish_size request for non-physical relish {}", rel ); } diff --git a/pageserver/src/relish.rs b/pageserver/src/relish.rs index 252a9122c0..7484e0848f 100644 --- a/pageserver/src/relish.rs +++ b/pageserver/src/relish.rs @@ -106,6 +106,23 @@ impl RelishTag { | RelishTag::Checkpoint => false, } } + + // Physical relishes represent files and use + // RelationSizeEntry to track existing and dropped files. + // They can be both blocky and non-blocky. + pub const fn is_physical(&self) -> bool { + match self { + // These relishes represent physical files + RelishTag::Relation(_) + | RelishTag::Slru { .. } + | RelishTag::FileNodeMap { .. } + | RelishTag::TwoPhase { .. } => true, + + // and these don't + | RelishTag::ControlFile + | RelishTag::Checkpoint => false, + } + } } ///