From a6c596001dbc1fd362f96d15ae95db6710c35190 Mon Sep 17 00:00:00 2001 From: Ayush Tiwari Date: Thu, 22 Oct 2026 19:08:19 +0530 Subject: [PATCH v1 1/2] Use half-open LSN ranges in FilterWalSummaries() FilterWalSummaries() also kept summaries that only touch the requested LSN range, unlike GetWalSummaries() and contrary to its own header comment. An incremental backup could therefore use an old-timeline summary that starts exactly at the timeline's switch point, although it covers only WAL that is not part of the server's history. A standby can have such a summary, because it summarizes received WAL ahead of replay, and recovery can end there at a recovery target. If that WAL truncated a relation, the summary's limit block could make the backup omit blocks modified on the new timeline, so pg_combinebackup restored stale data. Backpatch to 17, where incremental backup was introduced. Author: Ayush Tiwari Discussion: https://postgr.es/m/19774-8a1cbfd1774fcd0c@postgresql.org Backpatch-through: 17 --- src/backend/backup/walsummary.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/backend/backup/walsummary.c b/src/backend/backup/walsummary.c index 3d044a92417..8362c55e096 100644 --- a/src/backend/backup/walsummary.c +++ b/src/backend/backup/walsummary.c @@ -111,9 +111,9 @@ FilterWalSummaries(List *wslist, TimeLineID tli, /* Skip if it doesn't match the filter criteria. */ if (tli != 0 && tli != ws->tli) continue; - if (XLogRecPtrIsValid(start_lsn) && start_lsn > ws->end_lsn) + if (XLogRecPtrIsValid(start_lsn) && start_lsn >= ws->end_lsn) continue; - if (XLogRecPtrIsValid(end_lsn) && end_lsn < ws->start_lsn) + if (XLogRecPtrIsValid(end_lsn) && end_lsn <= ws->start_lsn) continue; /* Add it to the result list. */ -- 2.34.1