pgsql: Detect and fix visibility map corruption in more cases

From: Melanie Plageman <melanieplageman(at)gmail(dot)com>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Detect and fix visibility map corruption in more cases
Date: 2026-03-22 15:55:45
Message-ID: E1w4L9U-000xFD-0p@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Detect and fix visibility map corruption in more cases

Move VM corruption detection and repair into heap page pruning. This
allows VM repair during on-access pruning, not only during vacuum.

Also, expand corruption detection to cover pages marked all-visible that
contain dead tuples and tuples inserted or deleted by in-progress
transactions, rather than only all-visible pages with LP_DEAD items.

Pinning the correct VM page before on-access pruning is cheap when
compared to the cost of actually pruning. The vmbuffer is saved in the
scan descriptor, so a query should only need to pin each VM page once,
and a single VM page covers a large number of heap pages.

Author: Melanie Plageman <melanieplageman(at)gmail(dot)com>
Reviewed-by: Andres Freund <andres(at)anarazel(dot)de>
Reviewed-by: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Reviewed-by: Kirill Reshke <reshkekirill(at)gmail(dot)com>
Discussion: https://postgr.es/m/bqc4kh5midfn44gnjiqez3bjqv4zogydguvdn446riw45jcf3y%404ez66il7ebvk

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/4f7ecca84ddacbce27bdff3b78981a2bd9c9b242

Modified Files
--------------
src/backend/access/heap/pruneheap.c | 221 ++++++++++++++++++++++++++++++++---
src/backend/access/heap/vacuumlazy.c | 89 +-------------
src/include/access/heapam.h | 12 ++
src/tools/pgindent/typedefs.list | 1 +
4 files changed, 221 insertions(+), 102 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Geoghegan 2026-03-22 17:20:51 pgsql: Make IndexScanInstrumentation a pointer in executor scan nodes.
Previous Message Heikki Linnakangas 2026-03-22 12:29:21 pgsql: Don't reset 'latest_page_number' when replaying multixid truncat