Allow tuple visibility checks without hint-bit, maintenance

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Allow tuple visibility checks without hint-bit, maintenance
Date: 2026-08-28 20:06:46
Message-ID: be6ca231-f824-41e6-ad52-01fc962a665b@dunslane.net
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

Table AMs that store heap-format tuples on pages managed by another WAL
scheme (generic WAL, for example) can't tolerate
HeapTupleSatisfiesVisibility() and friends opportunistically writing
hint bits to the buffer: an unlogged write between two WAL operations
invalidates the before-image a later generic-WAL delta is computed
against, and standby replay ends up with a corrupt page.

The attached patch adds HeapTupleSatisfiesVisibilityNoHints() and
HeapTupleSatisfiesUpdateNoHints(), thin wrappers that return the same
verdict without touching the page. The sentinel that makes this work
(NoHintBitsBuffer) stays private to heapam_visibility.c.

Since NoHintBitsBuffer is negative, it passes BufferIsLocal(), so any
code reached from the wrappers that uses the buffer for something
besides hint bits needs to know about it. The one such case is
SNAPSHOT_HISTORIC_MVCC, which needs the buffer to recover the tuple's
relfilelocator; HeapTupleSatisfiesVisibilityNoHints() rejects that
snapshot type outright rather than let the sentinel reach it. In
practice this shouldn't fire: that snapshot type is only used for
logical decoding's catalog lookups, always against pg_catalog, which
is always heap.

(Thanks to Euler Taveira, who helped me with this, particularly with
criticizing an earlier and more invasive proposal.)

cheers

andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com

Attachment Content-Type Size
0001-Allow-tuple-visibility-checks-without-hint-bit-maint.patch text/x-patch 6.4 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message Daniel Gustafsson 2026-08-28 20:10:59 Re: Credits For v19
Previous Message Masahiko Sawada 2026-08-28 19:58:18 Should the WAIT FOR command tag be "WAIT" or "WAIT FOR"?