pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Zsolt Parragi <zsolt.parragi@percona.com>
Cc: Chao Li <li.evan.chao@gmail.com>
Cc: pgsql-hackers@lists.postgresql.org, Ewan Young <kdbase.hack@gmail.com>
Subject: Re: Introducing find_all_inheritors_ordered()
Date: Mon, 07 Sep 2026 19:38:10 -0400
Message-ID: <460958.1788824290@sss.pgh.pa.us> (raw)
In-Reply-To: <CAN4CZFNZD-1_XcEA+BGAi9_KgqzuONzecyVsMu9sB1Xp8+gHkg@mail.gmail.com>
References: <57100518-3FF1-48AD-B550-47B9A3E88688@gmail.com>
	<CAON2xHMcy+mr-bhZGT7cS3EzQWZ_Yc7OfTO+c9KV3SFacjfmfA@mail.gmail.com>
	<CAN4CZFNX_BPSKgkoUKf_2X6uUvUpd2CiGRYfj01Vgc8fd5GkTg@mail.gmail.com>
	<20EAC3F9-81A2-41DD-89FA-1539EA8ED11B@gmail.com>
	<CAN4CZFNZD-1_XcEA+BGAi9_KgqzuONzecyVsMu9sB1Xp8+gHkg@mail.gmail.com>

Zsolt Parragi <zsolt.parragi@percona.com> writes:
> On Mon, 07 Sep 2026, Chao Li <li.evan.chao@gmail.com> wrote:
>> My understanding is that PG doesn’t intend to support cyclic inheritance. The code explicitly rejects it:

> To me it seems like that it discourages it and tries to prevent it
> where it's possible to do so with reasonable effort, but it ends up
> trying to support it because it's a valid scenario that can happen in
> some workloads (as long as that also doesn't require too much effort).

Why is it a valid scenario, and how would we reach it?  It's going to
cause tons of problems if it can happen, so I'd rather put effort into
blocking it than making some parts of the system cope.

I have a different concern about the patch as it stands: the
data-gathering part is unnecessarily duplicative of
find_all_inheritors.  It does its best to look like it's doing
something different, but actually it computes exactly the same list
of relation OIDs and the same number-of-parents data.  And indeed
it had better be doing the same things in the same order, because
otherwise we'd be risking deadlock failures instead of simple
blocking when two processes are acquiring exclusive locks on
overlapping inheritance trees.  (Note the comment about "we need to be
sure all backends lock children in the same order to avoid needless
deadlocks" in find_inheritance_children.)  I don't like having two
independent implementations that are invisibly tied like that: if
they diverge, we might not notice until somebody makes a bug report
and somebody else figures out what's causing the deadlock.  So IMO
those two functions need to be revised to use a common data-gathering
step.

			regards, tom lane






view thread (10+ messages)  latest in thread

Message-ID: <460958.1788824290@sss.pgh.pa.us>
Permalink:  ../460958.1788824290@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/460958.1788824290@sss.pgh.pa.us

 · 

reply

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: tgl@sss.pgh.pa.us, zsolt.parragi@percona.com, li.evan.chao@gmail.com, kdbase.hack@gmail.com
  Subject: Re: Introducing find_all_inheritors_ordered()
  In-Reply-To: <460958.1788824290@sss.pgh.pa.us>
  References: <57100518-3FF1-48AD-B550-47B9A3E88688@gmail.com> <CAON2xHMcy+mr-bhZGT7cS3EzQWZ_Yc7OfTO+c9KV3SFacjfmfA@mail.gmail.com> <CAN4CZFNX_BPSKgkoUKf_2X6uUvUpd2CiGRYfj01Vgc8fd5GkTg@mail.gmail.com> <20EAC3F9-81A2-41DD-89FA-1539EA8ED11B@gmail.com> <CAN4CZFNZD-1_XcEA+BGAi9_KgqzuONzecyVsMu9sB1Xp8+gHkg@mail.gmail.com> <460958.1788824290@sss.pgh.pa.us>

* 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