pageserver: hold GC while reading from a timeline (#10559)

## Problem

If we are GC-ing because a new image layer was added while traversing
the timeline, then it will remove layers that are required for
fulfilling the current get request (read-path cannot "look back" and
notice the new image layer).

## Summary of Changes

Prevent GC from progressing on the current timeline while it is being
visited for a read.

Epic: https://github.com/neondatabase/neon/issues/9376
This commit is contained in:
Vlad Lazar
2025-01-29 17:08:25 +00:00
committed by GitHub
parent 190c19c034
commit fdfbc7b358

View File

@@ -3468,6 +3468,13 @@ impl Timeline {
let mut completed_keyspace = KeySpace::default();
let mut image_covered_keyspace = KeySpaceRandomAccum::new();
// Prevent GC from progressing while visiting the current timeline.
// If we are GC-ing because a new image layer was added while traversing
// the timeline, then it will remove layers that are required for fulfilling
// the current get request (read-path cannot "look back" and notice the new
// image layer).
let _gc_cutoff_holder = timeline.get_latest_gc_cutoff_lsn();
loop {
if cancel.is_cancelled() {
return Err(GetVectoredError::Cancelled);