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 pg_combinebackup handling of intermediate truncations
Date: Thu, 19 Nov 2026 07:11:44 +0000
Message-ID: <E1xTwJ5-00000000LoN-0vyU@gemulon.postgresql.org> (raw)

Fix pg_combinebackup handling of intermediate truncations

Restoring a backup with pg_combinebackup could bring back deleted
rows and leave tables inconsistent with their indexes. This could
happen when a relation was truncated before an intermediate
incremental backup and later extended with zero-filled pages that
were not recorded in WAL, as can occur during bulk relation extension
by COPY.

The problem was that pg_combinebackup used only the latest
incremental file's truncation_block_length to determine which blocks
could be copied from earlier backups. It ignored smaller truncation
limits in intermediate backups, allowing stale blocks from before a
truncation to be copied into pages that should have been zero-filled.

Fix this by tracking the truncation limit while walking backward
through the backup chain, lowering it after processing each incremental
file's own blocks. This prevents older backups from supplying blocks
at or beyond the limit while preserving blocks supplied by newer backups.

Backpatch to 17, where incremental backup was introduced.

Reported-by: Ke <kehan5800@gmail.com>
Author: Ke <kehan5800@gmail.com>
Author: Rajesh Kumar Thandapani <rajeshkumarth@google.com>
Reviewed-by: Raja Sai Pranav <rajasaipranav0@gmail.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/19776-c9e815f92ff29628@postgresql.org
Discussion: https://postgr.es/m/CAJoZ81s07r3akkKp-nJ8sgQNoCM0nu24g3HZ0FxTSY1OqsgurQ@mail.gmail.com
Backpatch-through: 17

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/4280abf88409d09e5828c4642219df053220a650

Modified Files
--------------
src/bin/pg_combinebackup/reconstruct.c | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)



view thread (4+ messages)  latest in thread

Message-ID: <E1xTwJ5-00000000LoN-0vyU@gemulon.postgresql.org>
Permalink:  ../E1xTwJ5-00000000LoN-0vyU@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1xTwJ5-00000000LoN-0vyU@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 pg_combinebackup handling of intermediate truncations
  In-Reply-To: <E1xTwJ5-00000000LoN-0vyU@gemulon.postgresql.org>
  References: <E1xTwJ5-00000000LoN-0vyU@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