pgsql: Fix parallel-safety marking when moving initplans to another nod

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Fix parallel-safety marking when moving initplans to another nod
Дата
Msg-id E1pmbkF-002iQS-HO@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Fix parallel-safety marking when moving initplans to another node.

Our policy since commit ab77a5a45 has been that a plan node having
any initplans is automatically not parallel-safe.  (This could be
relaxed, but not today.)  clean_up_removed_plan_level neglected
this, and could attach initplans to a parallel-safe child plan
node without clearing the plan's parallel-safe flag.  That could
lead to "subplan was not initialized" errors at runtime, in case
an initplan referenced another one and only the referencing one
got transmitted to parallel workers.

The fix in clean_up_removed_plan_level is trivial enough.
materialize_finished_plan also moves initplans from one node
to another, but it's okay because it already copies the source
node's parallel_safe flag.  The other place that does this kind
of thing is standard_planner's hack to inject a top-level Gather
when debug_parallel_query is active.  But that's actually dead
code given that we're correctly enforcing the "initplans aren't
parallel safe" rule, so just replace it with an Assert that
there are no initplans.

Also improve some related comments.

Normally we'd add a regression test case for this sort of bug.
The mistake itself is already reached by existing tests, but there
is accidentally no visible problem.  The only known test case that
creates an actual failure seems too indirect and fragile to justify
keeping it as a regression test (not least because it fails to fail
in v11, though the bug is clearly present there too).

Per report from Justin Pryzby.  Back-patch to all supported branches.

Discussion: https://postgr.es/m/ZDVt6MaNWkRDO1LQ@telsasoft.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/88ceac5d77f4ffb31f1e2d3df23d37e569ad5ff4

Modified Files
--------------
src/backend/optimizer/plan/planner.c   |  8 +++-----
src/backend/optimizer/plan/setrefs.c   | 14 +++++++++++++-
src/backend/optimizer/plan/subselect.c |  8 +++++---
src/backend/optimizer/util/pathnode.c  |  2 +-
4 files changed, 22 insertions(+), 10 deletions(-)


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

Предыдущее
От: Daniel Gustafsson
Дата:
Сообщение: pgsql: doc: Reword unexplained abbreviation
Следующее
От: Robert Haas
Дата:
Сообщение: pgsql: Document BaseBackupSync and BaseBackupWrite wait events.