pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Fix pg_combinebackup handling of intermediate truncations 4+ messages / 1 participants [nested] [flat]
* pgsql: Fix pg_combinebackup handling of intermediate truncations @ 2026-11-19 07:11 Fujii Masao <fujii@postgresql.org> 0 siblings, 0 replies; 4+ messages in thread From: Fujii Masao @ 2026-11-19 07:11 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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(-) ^ permalink raw reply [nested|flat] 4+ messages in thread
* pgsql: Fix pg_combinebackup handling of intermediate truncations @ 2026-11-19 07:11 Fujii Masao <fujii@postgresql.org> 0 siblings, 0 replies; 4+ messages in thread From: Fujii Masao @ 2026-11-19 07:11 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 ------ REL_19_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/94fb667004baea1da04e8ba0c5c574a7164b8036 Modified Files -------------- src/bin/pg_combinebackup/reconstruct.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) ^ permalink raw reply [nested|flat] 4+ messages in thread
* pgsql: Fix pg_combinebackup handling of intermediate truncations @ 2026-11-19 07:12 Fujii Masao <fujii@postgresql.org> 0 siblings, 0 replies; 4+ messages in thread From: Fujii Masao @ 2026-11-19 07:12 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 ------ REL_18_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/459595e3270d26cc0bc9b78602db1db4b82002af Modified Files -------------- src/bin/pg_combinebackup/reconstruct.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) ^ permalink raw reply [nested|flat] 4+ messages in thread
* pgsql: Fix pg_combinebackup handling of intermediate truncations @ 2026-11-19 07:12 Fujii Masao <fujii@postgresql.org> 0 siblings, 0 replies; 4+ messages in thread From: Fujii Masao @ 2026-11-19 07:12 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 ------ REL_17_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/47abddc25841147d4bb1743ca6bd51ac3c311fa3 Modified Files -------------- src/bin/pg_combinebackup/reconstruct.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) ^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2026-11-19 07:12 UTC | newest] Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2026-11-19 07:11 pgsql: Fix pg_combinebackup handling of intermediate truncations Fujii Masao <fujii@postgresql.org> 2026-11-19 07:11 pgsql: Fix pg_combinebackup handling of intermediate truncations Fujii Masao <fujii@postgresql.org> 2026-11-19 07:12 pgsql: Fix pg_combinebackup handling of intermediate truncations Fujii Masao <fujii@postgresql.org> 2026-11-19 07:12 pgsql: Fix pg_combinebackup handling of intermediate truncations Fujii Masao <fujii@postgresql.org>
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