postgres.git / summary / log / commit / refs

commit    ed89d84edc808e3f2edaf99f52a130ffc3db2413
Author:   Fujii Masao <fujii@postgresql.org>
Date:     Sun Nov 01 15:17:17 2026 +0000
First released in: 17.12, 18.7, 19.0

    Fix WAL summary boundary checks for incremental backups.
    
    A standby can summarize received WAL ahead of replay. If recovery ends
    exactly where an old-timeline summary begins, FilterWalSummaries()
    incorrectly includes that summary even though it covers only WAL outside
    the promoted server's history. Truncation information in the summary
    can cause an incremental backup to omit modified blocks, leading
    pg_combinebackup to reconstruct files with stale data from an earlier
    backup. For example, updated rows can revert to their previous values
    after restoring the backup.
    
    Fix this by excluding summaries that only touch the boundaries of the
    requested LSN range without overlapping it. This makes
    FilterWalSummaries() consistent with GetWalSummaries() and its existing
    function comments. The old-timeline summary starting at the switch point
    is thus excluded, preventing its truncation information from causing
    the backup to omit required modified blocks.
    
    Back-patch to PostgreSQL 17, where incremental backup was introduced.
    
    Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
    Reviewed-by: Chao Li <li.evan.chao@gmail.com>
    Reviewed-by: Manu <manuelreyesbravo@gmail.com>
    Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
    Reviewed-by: shihao zhong <zhong950419@gmail.com>
    Discussion: https://postgr.es/m/CAJTYsWV7RThdo4K62G8hC=Anpkbr54QWbOvyVvw5uvx4+-x_DQ@mail.gmail.com
    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 0cdc86af30b..3ef029d34e3 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. */ [parent: 4c0e3c1bfcf9]