Re: A few patches to clarify snapshot management
Noah Misch <noah@leadboat.com>
From: Noah Misch <noah@leadboat.com>
To: Heikki Linnakangas <hlinnaka@iki.fi>
Cc: Andres Freund <andres@anarazel.de>, Nathan Bossart <nathandbossart@gmail.com>, "pgsql-hackers@postgresql.org" <pgsql-hackers@postgresql.org>
Date: 2025-08-20T00:37:56Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Use ereport() rather than elog()
- 661f821ef0c3 19 (unreleased) landed
-
Revert GetTransactionSnapshot() to return historic snapshot during LR
- 27f20441c5e7 18.0 landed
- 50f770c3d92c 19 (unreleased) landed
-
Improve snapmgr.c comment
- 043745c3a01f 18.0 landed
-
Assert that a snapshot is active or registered before it's used
- 8076c00592e4 18.0 landed
-
Don't allow GetTransactionSnapshot() in logical decoding
- 1585ff7387db 18.0 landed
-
Remove unnecessary GetTransactionSnapshot() calls
- 952365cded63 18.0 landed
-
snapshot scalability: Don't compute global horizons while building snapshots.
- dc7420c2c927 14.0 cited
On Tue, Aug 19, 2025 at 11:45:01PM +0300, Heikki Linnakangas wrote:
> How about the attached, then? It reverts the GetTransactionSnapshot()
> change. But to still catch at least some of the invalid uses of the historic
> snapshot, it adds checks to heap_beginscan() and index_beginscan(), to
> complain if they are called on a non-catalog relation with a historic
> snapshot.
> @@ -1143,6 +1143,15 @@ heap_beginscan(Relation relation, Snapshot snapshot,
> if (!(snapshot && IsMVCCSnapshot(snapshot)))
> scan->rs_base.rs_flags &= ~SO_ALLOW_PAGEMODE;
>
> + /* Check that a historic snapshot is not used for non-catalog tables */
> + if (snapshot &&
> + IsHistoricMVCCSnapshot(snapshot) &&
> + !RelationIsAccessibleInLogicalDecoding(relation))
> + {
> + elog(ERROR, "cannot query non-catalog table \"%s\" during logical decoding",
> + RelationGetRelationName(relation));
> + }
> +
I feel post-beta3 is late for debut of restrictions like this. How about a
pure revert, then add those restrictions in v19? Should be s/elog/ereport/,
also.