From: Álvaro Herrera <alvherre@kurilemu.de>
To: Heikki Linnakangas <hlinnaka@iki.fi>
Cc: Andres Freund <andres@anarazel.de>
Cc: pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>
Cc: Chao Li <li.evan.chao@gmail.com>
Subject: Re: A few patches to clarify snapshot management, part 2
Date: Mon, 5 Jan 2026 14:01:12 -0300
Message-ID: <202601051648.6qlcg46owpjm@alvherre.pgsql> (raw)
In-Reply-To: <5ed502dd-2b42-4139-99e4-c34e7396afaf@iki.fi>
On 2025-Dec-22, Heikki Linnakangas wrote:
> @@ -146,7 +146,11 @@ find_inheritance_children_extended(Oid parentrelId, bool omit_detached,
> Snapshot snap;
>
> xmin = HeapTupleHeaderGetXmin(inheritsTuple->t_data);
> +
> + /* XXX: what should we do with a non-MVCC snapshot? */
> snap = GetActiveSnapshot();
> + if (snap->snapshot_type != SNAPSHOT_MVCC)
> + elog(ERROR, "cannot look up partition information with a non-MVCC snapshot");
>
> if (!XidInMVCCSnapshot(xmin, snap))
> {
I think this code should be skipped when a non-MVCC snapshot is in use.
I assume you won't hit the case unless you test for it specifically, so
I'm not surprised that just adding an elog(ERROR) does not cause visible
failures; however in production it probably would. And looking up
partition info in that case is, most likely, useless. So changing the
'if' test
if (!XidInMVCCSnapshot(xmin, snap))
to only do this dance if "->snapshot_type == SNAPSHOT_MVCC" seems
reasonable to me.
I'm not sure what's a good way to verify this, however. We would need a
test that adds partitions pending detach to partitioned tables used by
as many other tests as possible ... (Maybe: have test_setup.sql add an
event trigger that runs on CREATE TABLE, detects PARTITION BY, and
creates and partially detaches a partition. Not sure how feasible this
is.)
--
Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: alvherre@kurilemu.de, hlinnaka@iki.fi, andres@anarazel.de, li.evan.chao@gmail.com
Subject: Re: A few patches to clarify snapshot management, part 2
In-Reply-To: <202601051648.6qlcg46owpjm@alvherre.pgsql>
References: <5ed502dd-2b42-4139-99e4-c34e7396afaf@iki.fi> <202601051648.6qlcg46owpjm@alvherre.pgsql>
* 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