Re: Whan is it safe to mark a function PARALLEL SAFE?

Поиск
Список
Период
Сортировка
От Peter Geoghegan
Тема Re: Whan is it safe to mark a function PARALLEL SAFE?
Дата
Msg-id CAH2-WzmO2xg1G80HnBQjZ-YquowQxDR=dXLRynExdgLu3bfxTg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Whan is it safe to mark a function PARALLEL SAFE?  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Whan is it safe to mark a function PARALLEL SAFE?
Список pgsql-general
On Sun, Sep 8, 2019 at 12:27 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> > If an error is raised in one parallel worker, does this
> > cause the other parallel workers to be immediately terminated?
>
> I think not, though I didn't work on that code.  The error will
> be reported to the parent backend, which will cause it to fail
> the query ... but I think it just waits for the other worker
> children to exit first.  That's not something to rely on of course.
> Even if we don't make an attempt to cancel the other workers today
> we probably will in future.  But the cancel attempt would certainly
> be asynchronous, so I'm not sure how "immediate" you are worried
> about it being.

If workers call CHECK_FOR_INTERRUPTS() frequently, which they should,
then it should appear to users as if raising an error in one worker
kills everything almost immediately, or immediately.  For example, if
a parallel CREATE INDEX has a worker that raises a unique violation
error, that must work in a way that at least *appears* to be very
similar to what the user would get with a serial CREATE INDEX. (The
worst that can happen is that they'll very occasionally get two unique
violation errors instead of one, or something like that.)

That said, there are theoretical failures where it could take rather a
long time for the parent/leader to get the memo -- see
WaitForParallelWorkersToAttach() and its caller (note that anything
using a gather node is subject to the same kind of failure that
WaitForParallelWorkersToAttach() handles, even though they won't call
the function themselves). These failures (e.g. fork() failure) are
generally assumed to be rare to non-existent, though. Users will
surely be upset if parallel queries cannot be cancelled almost
immediately. If it happened with any regularity, somebody would have
complained by now.

As Tom said, it's hard to give a useful answer without more context --
how you define "immediate"?

-- 
Peter Geoghegan



В списке pgsql-general по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Whan is it safe to mark a function PARALLEL SAFE?
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: Convert a row to a nested JSON document containing all relationsin PostgreSQL