Prevent flip-flop of standby_horizon by ignoring 0 LSN and resetting it after each GC iteration

This commit is contained in:
Konstantin Knizhnik
2024-01-30 11:10:40 +02:00
parent 22a0a6ba0c
commit f24b898bef
13 changed files with 104 additions and 39 deletions

View File

@@ -631,6 +631,25 @@ impl PageServerHandler {
span,
)
}
PagestreamFeMessage::GetLatestPage(old_req) => {
let req = PagestreamGetPageRequest {
horizon: if old_req.latest {
Lsn::MAX
} else {
old_req.lsn
},
lsn: old_req.lsn,
rel: old_req.rel,
blkno: old_req.blkno,
};
let span = tracing::info_span!("handle_get_page_at_lsn_request", rel = %req.rel, blkno = %req.blkno, req_lsn = %req.lsn);
(
self.handle_get_page_at_lsn_request(tenant_id, timeline_id, &req, &ctx)
.instrument(span.clone())
.await,
span,
)
}
PagestreamFeMessage::GetPage(req) => {
// shard_id is filled in by the handler
let span = tracing::info_span!("handle_get_page_at_lsn_request", rel = %req.rel, blkno = %req.blkno, req_lsn = %req.lsn);

View File

@@ -4209,6 +4209,9 @@ impl Timeline {
new_gc_cutoff
};
// Reset standby horizon to ignore it if it is not updated till next GC
self.standby_horizon.store(Lsn::INVALID);
let res = self
.gc_timeline(horizon_cutoff, pitr_cutoff, retain_lsns, new_gc_cutoff)
.instrument(

View File

@@ -553,9 +553,12 @@ impl ConnectionManagerState {
fn register_timeline_update(&mut self, timeline_update: SafekeeperTimelineInfo) {
WALRECEIVER_BROKER_UPDATES.inc();
self.timeline
.standby_horizon
.store(Lsn(timeline_update.standby_horizon));
if timeline_update.standby_horizon != 0 {
// ignore reports from safekeepers mnot connected to replicas
self.timeline
.standby_horizon
.store(Lsn(timeline_update.standby_horizon));
}
let new_safekeeper_id = NodeId(timeline_update.safekeeper_id);
let old_entry = self.wal_stream_candidates.insert(