pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Fujii Masao <fujii@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix incremental backup data loss due to WAL summary merge order
Date: Sun, 01 Nov 2026 15:27:22 +0000
Message-ID: <E1xNXSs-00000001fhK-3w59@gemulon.postgresql.org> (raw)

Fix incremental backup data loss due to WAL summary merge order

An incremental backup taken after a relation is truncated and extended
again can omit modified blocks. Combining it with an earlier backup can
then restore stale data, causing live rows to disappear and deleted rows
to reappear.

WAL summaries were merged without ensuring LSN order. Applying a limit
block from an older summary after processing a newer summary could
discard references to blocks modified later, causing those blocks to
be omitted from the backup.

Sort the required summaries by ascending start LSN before merging them,
preserving references to later block modifications so that the required
blocks are included in the backup.

Backpatch to 17, where incremental backup was introduced.

Bug: #19774
Reported-by: Ke <kehan5800@gmail.com>
Author: Ke <kehan5800@gmail.com>
Co-authored-by: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Discussion: https://www.postgresql.org/message-id/19774-8a1cbfd1774fcd0c%40postgresql.org
Backpatch-through: 17

Branch
------
REL_17_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/9580e29da90c5f49cf34613d772ebbd5614882b1

Modified Files
--------------
src/backend/backup/basebackup_incremental.c     | 19 +++++
src/bin/pg_combinebackup/meson.build            |  1 +
src/bin/pg_combinebackup/t/013_summary_order.pl | 94 +++++++++++++++++++++++++
3 files changed, 114 insertions(+)



view thread (4+ messages)

Message-ID: <E1xNXSs-00000001fhK-3w59@gemulon.postgresql.org>
Permalink:  ../E1xNXSs-00000001fhK-3w59@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1xNXSs-00000001fhK-3w59@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: fujii@postgresql.org
  Subject: Re: pgsql: Fix incremental backup data loss due to WAL summary merge order
  In-Reply-To: <E1xNXSs-00000001fhK-3w59@gemulon.postgresql.org>
  References: <E1xNXSs-00000001fhK-3w59@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox