From: Tom Lane <tgl@sss.pgh.pa.us>
To: David Rowley <dgrowleyml@gmail.com>
Cc: Andreas Seltenreich <seltenreich@gmx.de>
Cc: pgsql-hackers@lists.postgresql.org
Subject: Re: [sqlsmith] Failed assertion during partition pruning
Date: Fri, 29 Jan 2021 15:28:26 -0500
Message-ID: <2823553.1611952106@sss.pgh.pa.us> (raw)
In-Reply-To: <1501458.1606854684@sss.pgh.pa.us>
References: <87sg8tqhsl.fsf@aurora.ydns.eu>
<919903.1606603948@sss.pgh.pa.us>
<1501458.1606854684@sss.pgh.pa.us>
I wrote:
>> What it looks like to me is that the code for setting up run-time
>> partition pruning has failed to consider the possibility of nested
>> partitioning: it's expecting that every partitioned table will have
>> at least one direct child that is a leaf. I'm not sure though
>> whether just the Assert is wrong, or there's more fundamental
>> issues here.
> After looking into the git history I realized that this assertion is
> quite new, stemming from David's a929e17e5a8 of 2020-11-02. So there's
> something not right about that.
I took some more time to poke at this today, and I now think that
the assertion in make_partitionedrel_pruneinfo is probably OK,
and what it's pointing out is a bug upstream in path creation.
Specifically, I noted that in
select a from trigger_parted where pg_trigger_depth() <> a order by a;
we arrive at make_partitionedrel_pruneinfo with partrelids equal
to (b 1 2), which seems to be correct. The RTE list is
RTE 1: trigger_parted
RTE 2: trigger_parted_p1
RTE 3: trigger_parted_p1_1
Like so much else of the partitioning code, AppendPath.partitioned_rels
is abysmally underdocumented, but what I think it means is the set of
non-leaf partitioned tables that are notionally scanned by the
AppendPath. The only table directly mentioned by the AppendPath's
subpath is RTE 3, so that all seems fine.
However, upon adding a LIMIT:
select a from trigger_parted where pg_trigger_depth() <> a order by a limit 40;
server closed the connection unexpectedly
we arrive at make_partitionedrel_pruneinfo with partrelids equal
to just (b 1); trigger_parted_p1 has been left out. The Path
in this case has been made by generate_orderedappend_paths, which
is what's responsible for computing AppendPath.partitioned_rels that
eventually winds up as the argument to make_partitionedrel_pruneinfo.
So I think that that code is somehow failing to account for nested
partitioning, while the non-ordered-append code is doing it right.
But I didn't spot exactly where the discrepancy is.
regards, tom lane
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, dgrowleyml@gmail.com, seltenreich@gmx.de
Subject: Re: [sqlsmith] Failed assertion during partition pruning
In-Reply-To: <2823553.1611952106@sss.pgh.pa.us>
References: <87sg8tqhsl.fsf@aurora.ydns.eu> <919903.1606603948@sss.pgh.pa.us> <1501458.1606854684@sss.pgh.pa.us> <2823553.1611952106@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