From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
Subject: | pgsql: Fix parallel-safety marking when moving initplans to another nod |
Date: | 2023-04-12 14:46:48 |
Message-ID: | E1pmbkF-002iQf-KM@gemulon.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
------
REL_11_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/60c8aeaf6745fa51cc893c48c626bc14c1009fde
Modified Files
--------------
src/backend/optimizer/plan/planner.c | 8 +++-----
src/backend/optimizer/plan/setrefs.c | 9 ++++++++-
src/backend/optimizer/plan/subselect.c | 8 +++++---
src/backend/optimizer/util/pathnode.c | 2 +-
4 files changed, 17 insertions(+), 10 deletions(-)
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Haas | 2023-04-12 15:30:36 | pgsql: Document BaseBackupSync and BaseBackupWrite wait events. |
Previous Message | Daniel Gustafsson | 2023-04-12 14:20:39 | pgsql: doc: Reword unexplained abbreviation |