From 166b61a88ef8e9fb97eba7b7ab8062e214c93af8 Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Wed, 18 Nov 2015 12:35:25 -0500 Subject: Avoid aggregating worker instrumentation multiple times. Amit Kapila, per design ideas from me. --- src/backend/executor/execParallel.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src/backend/executor/execParallel.c') diff --git a/src/backend/executor/execParallel.c b/src/backend/executor/execParallel.c index eae13c56477..67300377109 100644 --- a/src/backend/executor/execParallel.c +++ b/src/backend/executor/execParallel.c @@ -277,13 +277,15 @@ ExecParallelSetupTupleQueues(ParallelContext *pcxt, bool reinitialize) } /* - * Re-initialize the response queues for backend workers to return tuples - * to the main backend and start the workers. + * Re-initialize the parallel executor info such that it can be reused by + * workers. */ -shm_mq_handle ** -ExecParallelReinitializeTupleQueues(ParallelContext *pcxt) +void +ExecParallelReinitialize(ParallelExecutorInfo *pei) { - return ExecParallelSetupTupleQueues(pcxt, true); + ReinitializeParallelDSM(pei->pcxt); + pei->tqueue = ExecParallelSetupTupleQueues(pei->pcxt, true); + pei->finished = false; } /* @@ -308,6 +310,7 @@ ExecInitParallelPlan(PlanState *planstate, EState *estate, int nworkers) /* Allocate object for return value. */ pei = palloc0(sizeof(ParallelExecutorInfo)); + pei->finished = false; pei->planstate = planstate; /* Fix up and serialize plan to be sent to workers. */ @@ -469,6 +472,9 @@ ExecParallelFinish(ParallelExecutorInfo *pei) { int i; + if (pei->finished) + return; + /* First, wait for the workers to finish. */ WaitForParallelWorkersToFinish(pei->pcxt); @@ -480,6 +486,8 @@ ExecParallelFinish(ParallelExecutorInfo *pei) if (pei->instrumentation) ExecParallelRetrieveInstrumentation(pei->planstate, pei->instrumentation); + + pei->finished = true; } /* -- cgit v1.2.3