Skip to content

Commit

Permalink
pageserver: hold GC while reading from a timeline (neondatabase#10559)
Browse files Browse the repository at this point in the history
## 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: neondatabase#9376
  • Loading branch information
VladLazar authored and winter-loo committed Feb 4, 2025
1 parent cb7780c commit 709b3b7
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pageserver/src/tenant/timeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 709b3b7

Please sign in to comment.