pageserver: work around #9185 in layer visibility calculation

This commit is contained in:
John Spray
2024-10-15 15:17:29 +00:00
parent 73c6626b38
commit 0ed98977ba
2 changed files with 19 additions and 0 deletions

View File

@@ -392,6 +392,10 @@ impl InMemoryLayer {
self.end_lsn.get().copied().unwrap_or(Lsn::MAX)
}
pub(crate) fn start_lsn(&self) -> Lsn {
self.start_lsn
}
pub(crate) fn get_lsn_range(&self) -> Range<Lsn> {
self.start_lsn..self.end_lsn_or_max()
}

View File

@@ -646,6 +646,21 @@ impl Timeline {
readable_points.push(*child_lsn);
}
readable_points.push(head_lsn);
// The Timeline get page process will walk all InMemoryLayers before it starts walking historic
// layers. That means it might fail to see image layers that overlap with the LSN range of
// InMemoryLayers, so there is a de-facto read point at the start_lsn of the oldest InMemoryLayer.
//
// This behavior in the getpage path is considered a but, and including InMemoryLayer's start_lsn here
// is a workaround. See https://github.com/neondatabase/neon/issues/9185
if let Some(oldest_inmemory_layer) = layer_map.frozen_layers.front() {
readable_points.push(oldest_inmemory_layer.start_lsn())
} else if let Some(open_layer) = layer_map.open_layer.as_ref() {
readable_points.push(open_layer.start_lsn());
}
readable_points.sort();
readable_points
};