pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Amit Kapila <amit.kapila16@gmail.com>
Cc: Stephen Frost <sfrost@snowman.net>
Cc: Marko Tiikkaja <marko@joh.to>
Cc: Andres Freund <andres@anarazel.de>
Cc: Andrew Fletcher <andy@prestigedigital.com>
Cc: PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Subject: Re: BUG #15324: Non-deterministic behaviour from parallelised sub-query
Date: Sun, 02 Sep 2018 14:55:20 -0400
Message-ID: <15719.1535914520@sss.pgh.pa.us> (raw)
In-Reply-To: <CAA4eK1+x+EzkkNjH3DqHdObJ-9+m2eAOzQj5Z6hmOR12JCA56A@mail.gmail.com>
References: <CAL9smLBPZJOUWjHKgZOQaDO5FK+AkkX61BT06mpSfiNz4wdtgw@mail.gmail.com>
	<21038.1534181205@sss.pgh.pa.us>
	<CAA4eK1+1yszJgG3WBnMrRAEsBymH871c3O8UQtq3iif=siOc0g@mail.gmail.com>
	<CAL9smLAnfPJCDUUG4ckX2iznj53V7VSMsYefzZieN93YxTNOcw@mail.gmail.com>
	<CAA4eK1J-_LxN5hc6ikh=vZ4vr6Yt6eFM57gMHkFzBCRTo791Bg@mail.gmail.com>
	<CAL9smLDj9Nwm0yzShEGjfNfkNc+NzCHmHwNXFOkwp74Oj3r84g@mail.gmail.com>
	<CAA4eK1LUQX0HR_9TieA0DYpYcWFjGT-CPJ9E+HV4OnzusFY8VQ@mail.gmail.com>
	<CAL9smLD+d+Bi1tvA8og5J+ZrW2E-yuyL1w4k2CdX3Fxb-vWDOQ@mail.gmail.com>
	<390.1534261450@sss.pgh.pa.us>
	<CAA4eK1+6U0fOLMdMMk-iMC-6RSM+70p-9YqCVnWTEBH=V73Agg@mail.gmail.com>
	<20180815111006.GB3326@tamriel.snowman.net>
	<CAA4eK1JqimRvJt5=nuukG+hXGA0P2tD=D0ewYrO4u0ig_TTacg@mail.gmail.com>
	<CAA4eK1JyvN1dnBRJeor6LT2sjcjoyq8eb0N6pZ2fOZRrdZe3ow@mail.gmail.com>
	<CAA4eK1JBc67MjYjo2EXwNiyUuoFqwcR4zeSyGt6zS2F0MpJABA@mail.gmail.com>
	<19350.1534771766@sss.pgh.pa.us>
	<CAA4eK1K2zQqks=2sLC9MAJhbE3oQM-BK5e8KCd-v+vfxiMj-=g@mail.gmail.com>
	<CAA4eK1! +x+EzkkNjH3DqHdObJ-9+m2eAOzQj5Z6hmOR12JCA56A@mail.gmail.com>

Amit Kapila <amit.kapila16@gmail.com> writes:
> Tom, do you have input on this?  Is it okay to backpatch this fix?

Well,

>> + * Treat window functions as parallel-restricted as the row ordering
>> + * induced by them is non-deterministic.  We can relax this condition for
>> + * cases where the row ordering can be deterministic like when there is
>> + * an ORDER BY on the primary key, but those cases don't seem to be
>> + * interesting enough to have additional checks.

This comment seems fairly confused.  I'd say something like

 * Treat window functions as parallel-restricted because we aren't sure
 * whether the input row ordering is fully deterministic, and the output
 * of window functions might vary across workers if not.  (In some cases,
 * like where the window frame orders by a primary key, we could relax
 * this restriction.  But it doesn't currently seem worth expending extra
 * effort to do so.)

>> In addition to the above, I have marked all built-in window functions
>> as parallel-restricted.  I think even if we don't do that something
>> like above check should be sufficient, but OTOH, I don't see any
>> reason to keep the marking of such functions as parallel-safe.  Is
>> there a reason, why we shouldn't mark them as parallel-restricted?

I am *strongly* against this.  It's unnecessary catalog churn that we
might need to undo someday, and it confuses a property of the window
function infrastructure with a property of individual window functions.
As a counterexample, if a window function were parallel-unsafe for
some reason, we'd surely need to honor that.  More realistically,
someone might add a window function that actually needs to be
parallel-restricted for reasons of its own, but then there would be
no obvious distinction between such a function and one that you'd
hacked up to be marked parallel-restricted even though it's safe in
itself.  If we then do make the sort of optimization suggested in the
comment, it's likely that someone would just s/r/s/g for all the window
functions and thereby break such a function.  Better to retain the
correct per-function markings.

			regards, tom lane




view thread (38+ messages)  latest in thread

Message-ID: <15719.1535914520@sss.pgh.pa.us>
Permalink:  ../15719.1535914520@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/15719.1535914520@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-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, amit.kapila16@gmail.com, sfrost@snowman.net, marko@joh.to, andres@anarazel.de, andy@prestigedigital.com
  Subject: Re: BUG #15324: Non-deterministic behaviour from parallelised sub-query
  In-Reply-To: <15719.1535914520@sss.pgh.pa.us>
  References: <CAL9smLBPZJOUWjHKgZOQaDO5FK+AkkX61BT06mpSfiNz4wdtgw@mail.gmail.com> <CAA4eK1+1yszJgG3WBnMrRAEsBymH871c3O8UQtq3iif=siOc0g@mail.gmail.com> <CAL9smLAnfPJCDUUG4ckX2iznj53V7VSMsYefzZieN93YxTNOcw@mail.gmail.com> <CAA4eK1J-_LxN5hc6ikh=vZ4vr6Yt6eFM57gMHkFzBCRTo791Bg@mail.gmail.com> <CAL9smLDj9Nwm0yzShEGjfNfkNc+NzCHmHwNXFOkwp74Oj3r84g@mail.gmail.com> <CAA4eK1LUQX0HR_9TieA0DYpYcWFjGT-CPJ9E+HV4OnzusFY8VQ@mail.gmail.com> <CAL9smLD+d+Bi1tvA8og5J+ZrW2E-yuyL1w4k2CdX3Fxb-vWDOQ@mail.gmail.com> <390.1534261450@sss.pgh.pa.us> <CAA4eK1+6U0fOLMdMMk-iMC-6RSM+70p-9YqCVnWTEBH=V73Agg@mail.gmail.com> <20180815111006.GB3326@tamriel.snowman.net> <CAA4eK1JqimRvJt5=nuukG+hXGA0P2tD=D0ewYrO4u0ig_TTacg@mail.gmail.com> <CAA4eK1JyvN1dnBRJeor6LT2sjcjoyq8eb0N6pZ2fOZRrdZe3ow@mail.gmail.com> <CAA4eK1JBc67MjYjo2EXwNiyUuoFqwcR4zeSyGt6zS2F0MpJABA@mail.gmail.com> <19350.1534771766@sss.pgh.pa.us> <CAA4eK1K2zQqks=2sLC9MAJhbE3oQM-BK5e8KCd-v+vfxiMj-=g@mail.gmail.com> <15719.1535914520@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