aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor/execParallel.c
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2017-12-18 12:17:37 -0500
committerRobert Haas <rhaas@postgresql.org>2017-12-18 12:31:10 -0500
commitb70ea4c75e5f94fd7757ea4a522aee6724885288 (patch)
tree759daa20f034ced5ca0fcb5c8d0a46e58ee28d6d /src/backend/executor/execParallel.c
parentac93acbc05be2ef995208c1ca17f8083f60ccc53 (diff)
downloadpostgresql-b70ea4c75e5f94fd7757ea4a522aee6724885288.tar.gz
postgresql-b70ea4c75e5f94fd7757ea4a522aee6724885288.zip
Fix crashes on plans with multiple Gather (Merge) nodes.
es_query_dsa turns out to be broken by design, because it supposes that there is only one DSA for the whole query, whereas there is actually one per Gather (Merge) node. For now, work around that problem by setting and clearing the pointer around the sections of code that might need it. It's probably a better idea to get rid of es_query_dsa altogether in favor of having each node keep track individually of which DSA is relevant, but that seems like more than we would want to back-patch. Thomas Munro, reviewed and tested by Andreas Seltenreich, Amit Kapila, and by me. Discussion: http://postgr.es/m/CAEepm=1U6as=brnVvMNixEV2tpi8NuyQoTmO8Qef0-VV+=7MDA@mail.gmail.com
Diffstat (limited to 'src/backend/executor/execParallel.c')
-rw-r--r--src/backend/executor/execParallel.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/backend/executor/execParallel.c b/src/backend/executor/execParallel.c
index 7dda399daf3..989cf5b80b1 100644
--- a/src/backend/executor/execParallel.c
+++ b/src/backend/executor/execParallel.c
@@ -544,12 +544,6 @@ ExecInitParallelPlan(PlanState *planstate, EState *estate, int nworkers)
}
/*
- * Make the area available to executor nodes running in the leader. See
- * also ParallelQueryMain which makes it available to workers.
- */
- estate->es_query_dsa = pei->area;
-
- /*
* Give parallel-aware nodes a chance to initialize their shared data.
* This also initializes the elements of instrumentation->ps_instrument,
* if it exists.
@@ -557,7 +551,11 @@ ExecInitParallelPlan(PlanState *planstate, EState *estate, int nworkers)
d.pcxt = pcxt;
d.instrumentation = instrumentation;
d.nnodes = 0;
+
+ /* Install our DSA area while initializing the plan. */
+ estate->es_query_dsa = pei->area;
ExecParallelInitializeDSM(planstate, &d);
+ estate->es_query_dsa = NULL;
/*
* Make sure that the world hasn't shifted under our feet. This could
@@ -609,6 +607,8 @@ void
ExecParallelReinitialize(PlanState *planstate,
ParallelExecutorInfo *pei)
{
+ EState *estate = planstate->state;
+
/* Old workers must already be shut down */
Assert(pei->finished);
@@ -618,7 +618,9 @@ ExecParallelReinitialize(PlanState *planstate,
pei->finished = false;
/* Traverse plan tree and let each child node reset associated state. */
+ estate->es_query_dsa = pei->area;
ExecParallelReInitializeDSM(planstate, pei->pcxt);
+ estate->es_query_dsa = NULL;
}
/*