Re: [COMMITTERS] pgsql: Improve access to parallel query from procedural languages.

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Rafia Sabih <rafia(dot)sabih(at)enterprisedb(dot)com>, PostgreSQL Developers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [COMMITTERS] pgsql: Improve access to parallel query from procedural languages.
Date: 2017-03-27 13:48:52
Message-ID: CA+TgmoZRB1zkVr88LTiGGFx0AL7Fk5_D27GSgE4-+s2tz-tsTA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

On Mon, Mar 27, 2017 at 9:25 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Robert Haas <robertmhaas(at)gmail(dot)com> writes:
>> On Mon, Mar 27, 2017 at 1:48 AM, Rafia Sabih
>> <rafia(dot)sabih(at)enterprisedb(dot)com> wrote:
>>> This is caused because trigger related functions are marked safe and
>>> using global variables, hence when executed in parallel are giving
>>> incorrect output.
>
>> If it's just that they are relying on unsynchronized global variables,
>> then it's sufficient to mark them parallel-restricted ('r'). Do we
>> really need to go all the way to parallel-unsafe ('u')?
>
> Color me confused, but under what circumstances would triggers get
> executed by a parallel worker at all? I thought we did not allow
> updating queries to be parallelized.

Right, we don't. But if the updating query fires a trigger, and the
trigger runs an SQL statement that is itself safe for parallelism,
*that* statement could be run in parallel. In almost all cases it
won't make sense because triggers aren't likely to contain SQL
statements that are expensive enough to justify running them in
parallel, but there's no a priori reason to disallow it.

(And, indeed, I think this commit and the subsequent breakage shows
the value of making sure that parallel query is allowed in as many
places as possible. Running the regression tests with
force_parallel_mode=regress is the best automated tool we have to find
cases where functions are labeled as being more safe than they
actually are, but those tests only try inserting the invisible
single-copy Gather node in cases where parallel query is allowable at
all.)

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Eisentraut 2017-03-27 14:37:12 pgsql: Change default of log_directory to 'log'
Previous Message Tom Lane 2017-03-27 13:25:19 Re: [COMMITTERS] pgsql: Improve access to parallel query from procedural languages.

Browse pgsql-hackers by date

  From Date Subject
Next Message Andreas Karlsson 2017-03-27 13:50:29 Re: Refactor handling of database attributes between pg_dump and pg_dumpall
Previous Message Dagfinn Ilmari =?utf-8?Q?Manns=C3=A5ker?= 2017-03-27 13:48:46 Re: perlcritic