pgsql: Forget invalid VM pages during truncation replay

From: Melanie Plageman <melanieplageman(at)gmail(dot)com>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Forget invalid VM pages during truncation replay
Date: 2026-11-19 22:16:15
Message-ID: E1xUAQQ-00000000RBd-1SWF@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Forget invalid VM pages during truncation replay

Commit ed62d26caca made heap records that clear visibility map bits
register VM blocks, causing redo to read those blocks with RBM_NORMAL.
If such a record is replayed after the VM fork was already truncated on
disk, recovery records a missing-page reference. Replaying the
truncation only forgot missing pages from the main fork, so recovery
later PANICs with unresolved invalid pages.

Call XLogTruncateRelation() for the VM fork when replaying a VM
truncation.

Reported-by: Jacky Nguyen <nktpro(at)gmail(dot)com>
Reviewed-by: Kirill Reshke <reshkekirill(at)gmail(dot)com>
Reviewed-by: Shihao Zhong <zhong950419(at)gmail(dot)com>
Reviewed-by: Rahul Yadav <rahul(at)rhyadav(dot)dev>
Discussion: https://postgr.es/m/CAL4mQLAp562c1rCgg2Dqx6TBSdOk6vOvaLFjwFG9E6k4uwvJJw%40mail.gmail.com
Backpatch-through: 17

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/c266e204a7ab76f79178ed94aa2f679def0bff9d

Modified Files
--------------
.../pg_visibility/t/001_concurrent_transaction.pl | 51 +++++++++++++++++++++-
src/backend/catalog/storage.c | 12 ++++-
2 files changed, 60 insertions(+), 3 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Melanie Plageman 2026-11-19 22:17:09 pgsql: Avoid overflow computing visibility map length
Previous Message Melanie Plageman 2026-11-19 21:21:13 pgsql: Fix WAL-logged CREATE DATABASE with nonstandard pages