From: Tom Lane <tgl@sss.pgh.pa.us>
To: Amit Kapila <amit.kapila16@gmail.com>
Cc: Andreas Seltenreich <seltenreich@gmx.de>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Subject: Re: [sqlsmith] Failed assertion in parallel worker in ExecInitSubPlan
Date: Fri, 25 Nov 2016 16:34:39 -0500
Message-ID: <5416.1480109679@sss.pgh.pa.us> (raw)
In-Reply-To: <CAA4eK1LkH9TXgM_+tJ8wt9Oyj0ZitM+cVsvZq51xjXe8QSBvRA@mail.gmail.com>
References: <8737im6pmh.fsf@credativ.de>
<CAA4eK1KHO2bVkeiDuRmruwZs-VqNRmqRmiVcN6PRfW1HpgPrpg@mail.gmail.com>
<CAA4eK1+0MUZUvMNuO6SLzjEwD2KVWssDL3G=AiBHHQTzxWnm1w@mail.gmail.com>
<19006.1479744058@sss.pgh.pa.us>
<874m2w4k5d.fsf@ex.ansel.ydns.eu>
<CAA4eK1+op4QY_N+bQg1+KxH8rMuohSKg3ogXDyHHbf66qZV9GA@mail.gmail.com>
<17582.1480050207@sss.pgh.pa.us>
<CAA4eK1LkH9TXgM_+tJ8wt9Oyj0ZitM+cVsvZq51xjXe8QSBvRA@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>
Amit Kapila <amit.kapila16@gmail.com> writes:
> On Fri, Nov 25, 2016 at 10:33 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> The impression I got in poking at this for a few minutes, before
>> going off to stuff myself with turkey, was that we were allowing
>> a SubqueryScanPath to mark itself as parallel-safe even though the
>> resulting plan node would have an InitPlan attached. So my thought
>> about fixing it was along the lines of if-subroot-contains-initplans-
>> then-dont-let-SubqueryScanPath-be-parallel-safe.
> I think this will work for the reported case, see the patch attached.
After further thought, it seems to me that the fundamental error here
is that we're not accounting for initPlans while marking paths as
parallel safe or not. They should be correctly marked when they come
out of subquery_planner, rather than expecting callers to know that
they can't trust that marking. That way, we don't need to do anything
special in create_subqueryscan_path, and we can also get rid of that
kluge in the force_parallel_mode logic.
> However, don't we need to worry about if there is a subplan
> (non-initplan) instead of initplan.
I don't think so. References to subplans are already known to be parallel
restricted. The issue that we're fixing here is that if a plan node has
initPlans attached, ExecutorStart will try to access those subplans,
whether or not they actually get used while running. That's why the plan
node itself has to be marked parallel-unsafe so it won't get shipped to
parallel workers.
>> There's another issue here, which is that the InitPlan is derived from an
>> outer join qual whose outer join seems to have been deleted entirely by
>> analyzejoins.c. Up to now it was possible to avert our eyes from the fact
>> that join removal is lazy about getting rid of unused InitPlans, but if
>> they're going to disable parallelization of the surrounding query, maybe
>> we need to work harder on that.
> Yeah, that makes sense, but not sure whether we should try it along
> with this patch.
I'm not certain that sublinks in deletable outer join quals is a case
important enough to sweat over. But this is the first time I've realized
that failure to remove those initPlans is capable of making a plan worse.
So it's something to keep an eye on. (I still wish that we could make
join removal happen during join tree preprocessing; doing it where it is
is nothing but a kluge, with unpleasant side effects like this one.)
regards, tom lane
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
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, amit.kapila16@gmail.com, seltenreich@gmx.de, robertmhaas@gmail.com
Subject: Re: [sqlsmith] Failed assertion in parallel worker in ExecInitSubPlan
In-Reply-To: <5416.1480109679@sss.pgh.pa.us>
References: <8737im6pmh.fsf@credativ.de> <CAA4eK1KHO2bVkeiDuRmruwZs-VqNRmqRmiVcN6PRfW1HpgPrpg@mail.gmail.com> <CAA4eK1+0MUZUvMNuO6SLzjEwD2KVWssDL3G=AiBHHQTzxWnm1w@mail.gmail.com> <19006.1479744058@sss.pgh.pa.us> <874m2w4k5d.fsf@ex.ansel.ydns.eu> <CAA4eK1+op4QY_N+bQg1+KxH8rMuohSKg3ogXDyHHbf66qZV9GA@mail.gmail.com> <17582.1480050207@sss.pgh.pa.us> <CAA4eK1LkH9TXgM_+tJ8wt9Oyj0ZitM+cVsvZq51xjXe8QSBvRA@mail.gmail.com> <5416.1480109679@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