pgsql: Fix WAL summary boundary checks for incremental backups.

From: Fujii Masao <fujii(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix WAL summary boundary checks for incremental backups.
Date: 2026-11-01 15:26:27
Message-ID: E1xNXRz-00000001fdg-06Lz@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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(dot)slg01(at)gmail(dot)com>
Reviewed-by: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Reviewed-by: Manu <manuelreyesbravo(at)gmail(dot)com>
Reviewed-by: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Reviewed-by: shihao zhong <zhong950419(at)gmail(dot)com>
Discussion: https://postgr.es/m/CAJTYsWV7RThdo4K62G8hC=Anpkbr54QWbOvyVvw5uvx4+-x_DQ@mail.gmail.com
Backpatch-through: 17

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/f549ecd2660ad3c6d56a07835756068d43d4a92c

Modified Files
--------------
src/backend/backup/walsummary.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Fujii Masao 2026-11-01 15:26:58 pgsql: Fix incremental backup data loss due to WAL summary merge order
Previous Message Heikki Linnakangas 2026-10-31 11:47:29 pgsql: Fix two crashes on a concurrently dropped schema