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 <[email protected]> Author: Ke <[email protected]> Co-authored-by: Fujii Masao <[email protected]> Reviewed-by: Ayush Tiwari <[email protected]> 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(+)
