pageserver: permit reads behind GC cutoff while in LSN lease grace period

This commit is contained in:
John Spray
2024-11-21 10:14:55 +00:00
parent 42bda5d632
commit c7d3bd105c
2 changed files with 9 additions and 1 deletions

View File

@@ -1068,7 +1068,7 @@ impl PageServerHandler {
));
}
if request_lsn < **latest_gc_cutoff_lsn {
if request_lsn < **latest_gc_cutoff_lsn && !timeline.is_gc_blocked_by_lsn_lease_deadline() {
let gc_info = &timeline.gc_info.read().unwrap();
if !gc_info.leases.contains_key(&request_lsn) {
// The requested LSN is below gc cutoff and is not guarded by a lease.
@@ -1078,6 +1078,9 @@ impl PageServerHandler {
return Err(if request_lsn == Lsn::INVALID {
PageStreamError::BadRequest("invalid LSN(0) in request".into())
} else {
// Although we might still have this data, we return an error to more readily
// detect client misbehavior: clients should only read from recent LSNs on their
// timeline, or from locations holding an LSN lease.
PageStreamError::BadRequest(format!(
"tried to request a page version that was garbage collected. requested at {} gc cutoff {}",
request_lsn, **latest_gc_cutoff_lsn

View File

@@ -2085,6 +2085,11 @@ impl Timeline {
.unwrap_or(self.conf.default_tenant_conf.lsn_lease_length_for_ts)
}
pub(crate) fn is_gc_blocked_by_lsn_lease_deadline(&self) -> bool {
let tenant_conf = self.tenant_conf.load();
tenant_conf.is_gc_blocked_by_lsn_lease_deadline()
}
pub(crate) fn get_lazy_slru_download(&self) -> bool {
let tenant_conf = self.tenant_conf.load();
tenant_conf