postgresql/src/include/nodes
Tom Lane 16ebab6886 Avoid transferring parallel-unsafe subplans to parallel workers.
Commit 5e6d8d2bb allowed parallel workers to execute parallel-safe
subplans, but it transmitted the query's entire list of subplans to
the worker(s).  Since execMain.c blindly does ExecInitNode and later
ExecEndNode on every list element, this resulted in parallel-unsafe plan
nodes nonetheless getting started up and shut down in parallel workers.
That seems mostly harmless as far as core plan node types go (but
maybe not so much for Gather?).  But it resulted in postgres_fdw
opening and then closing extra remote connections, and it's likely
that other non-parallel-safe FDWs or custom scan providers would have
worse reactions.

To fix, just make ExecSerializePlan replace parallel-unsafe subplans
with NULLs in the cut-down plan tree that it transmits to workers.
This relies on ExecInitNode and ExecEndNode to do nothing on NULL
input, but they do anyway.  If anything else is touching the dropped
subplans in a parallel worker, that would be a bug to be fixed.
(This thus provides a strong guarantee that we won't try to do
something with a parallel-unsafe subplan in a worker.)

This is, I think, the last fix directly occasioned by Andreas Seltenreich's
bug report of a few days ago.

Tom Lane and Amit Kapila

Discussion: https://postgr.es/m/87tw5x4vcu.fsf@credativ.de
2017-04-12 16:07:00 -04:00
..
bitmapset.h Support hashed aggregation with grouping sets. 2017-03-27 04:20:54 +01:00
execnodes.h Optimize joins when the inner relation can be proven unique. 2017-04-07 22:20:13 -04:00
extensible.h Allow custom and foreign scans to have shutdown callbacks. 2017-02-26 13:41:12 +05:30
lockoptions.h Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
makefuncs.h Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
memnodes.h Add "Slab" MemoryContext implementation for efficient equal-sized allocations. 2017-02-27 03:41:44 -08:00
nodeFuncs.h Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
nodes.h Identity columns 2017-04-06 08:41:37 -04:00
params.h Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
parsenodes.h Identity columns 2017-04-06 08:41:37 -04:00
pg_list.h Improve castNode notation by introducing list-extraction-specific variants. 2017-04-10 13:51:53 -04:00
plannodes.h Avoid transferring parallel-unsafe subplans to parallel workers. 2017-04-12 16:07:00 -04:00
primnodes.h Identity columns 2017-04-06 08:41:37 -04:00
print.h Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
readfuncs.h Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
relation.h Optimize joins when the inner relation can be proven unique. 2017-04-07 22:20:13 -04:00
replnodes.h Logical replication support for initial data copy 2017-03-23 08:55:37 -04:00
tidbitmap.h tidbitmap: Support shared iteration. 2017-03-08 08:09:38 -05:00
value.h Update copyright via script for 2017 2017-01-03 13:48:53 -05:00