From: Andres Freund <andres@anarazel.de>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix bug due to confusion about what IsMVCCSnapshot means
Date: Fri, 13 Mar 2026 17:55:47 +0000
Message-ID: <E1w16ji-0000RT-1N@gemulon.postgresql.org> (raw)
Fix bug due to confusion about what IsMVCCSnapshot means
In 0b96e734c59 I (Andres) relied on page_collect_tuples() being called only
with an MVCC snapshot, and added assertions to that end, but did not realize
that IsMVCCSnapshot() allows both proper MVCC snapshots and historical
snapshots, which behave quite similarly to MVCC snapshots.
Unfortunately that can lead to incorrect visibility results during logical
decoding, as a historical snapshot is interpreted as a plain MVCC
snapshot. The only reason this wasn't noticed earlier is that it's hard to
reach as most of the time there are no sequential scans during logical
decoding.
To fix the bug and avoid issues like this in the future, split
IsMVCCSnapshot() into IsMVCCSnapshot() and IsMVCCLikeSnapshot(), where now
only the latter includes historic snapshots.
One effect of this is that during logical decoding no page-at-a-time snapshots
are used, as otherwise runtime branches to handle historic snapshots would be
needed in some performance critical paths. Given how uncommon sequential scans
are during logical decoding, that seems acceptable.
Author: Antonin Houska <ah@cybertec.at>
Reported-by: Antonin Houska <ah@cybertec.at>
Discussion: https://postgr.es/m/61812.1770637345@localhost
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/ce5d489166e5c8437aa1a35f462f67f1aeae87d4
Modified Files
--------------
src/backend/access/heap/heapam_handler.c | 2 +-
src/backend/access/index/indexam.c | 2 +-
src/backend/access/nbtree/nbtree.c | 2 +-
src/include/utils/snapmgr.h | 21 ++++++++++++++++++---
4 files changed, 21 insertions(+), 6 deletions(-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-committers@postgresql.org
Cc: andres@anarazel.de, pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: Fix bug due to confusion about what IsMVCCSnapshot means
In-Reply-To: <E1w16ji-0000RT-1N@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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