| From: | Fujii Masao <fujii(at)postgresql(dot)org> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Fix pg_combinebackup handling of intermediate truncations |
| Date: | 2026-11-19 07:11:44 |
| Message-ID: | E1xTwJ5-00000000LoN-0vyU@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
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(at)gmail(dot)com>
Author: Ke <kehan5800(at)gmail(dot)com>
Author: Rajesh Kumar Thandapani <rajeshkumarth(at)google(dot)com>
Reviewed-by: Raja Sai Pranav <rajasaipranav0(at)gmail(dot)com>
Reviewed-by: Fujii Masao <masao(dot)fujii(at)gmail(dot)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(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Fujii Masao | 2026-11-19 07:11:57 | pgsql: Fix pg_combinebackup handling of intermediate truncations |
| Previous Message | shihao zhong | 2026-11-19 05:01:29 | Re: pgsql: Don't trust NOT NULL on virtual generated columns of partitioned |