Re: Parallel Seq Scan
От | Robert Haas |
---|---|
Тема | Re: Parallel Seq Scan |
Дата | |
Msg-id | CA+TgmoY=bGOFUHQQRxOwSsjfbbgmjZiCti_jA2QnZYWgt2Vqew@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: Parallel Seq Scan (Amit Kapila <amit.kapila16@gmail.com>) |
Ответы |
Re: Parallel Seq Scan
|
Список | pgsql-hackers |
On Thu, Nov 12, 2015 at 10:23 AM, Amit Kapila <amit.kapila16@gmail.com> wrote: > Thanks for the report. The reason for this problem is that instrumentation > information from workers is getting aggregated multiple times. In > ExecShutdownGatherWorkers(), we call ExecParallelFinish where it > will wait for workers to finish and then accumulate stats from workers. > Now ExecShutdownGatherWorkers() could be called multiple times > (once we read all tuples from workers, at end of node) and it should be > ensured that repeated calls should not try to redo the work done by first > call. > The same is ensured for tuplequeues, but not for parallel executor info. > I think we can safely assume that we need to call ExecParallelFinish() only > when there are workers started by the Gathers node, so on those lines > attached patch should fix the problem. I suggest that we instead fix ExecParallelFinish() to be idempotent. Add a "bool finished" flag to ParallelExecutorInfo and return at once if it's already set. Get rid of the exposed ExecParallelReinitializeTupleQueues() interface and have ExecParallelReinitialize(pei) instead. Have that call ReinitializeParallelDSM(), ExecParallelSetupTupleQueues(pei->pcxt, true), and set pei->finished = false. I think that would give us a slightly cleaner separation of concerns between nodeGather.c and execParallel.c. Your fix seems a little fragile. You're relying on node->reader != NULL to tell you whether the readers need to be cleaned up, but in fact node->reader is set to a non-NULL value AFTER the pei has been created. Granted, we currently always create a reader unless we don't get any workers, and if we don't get any workers then failing to call ExecParallelFinish is currently harmless, but nonetheless I think we should be more explicit about this so it doesn't accidentally get broken later. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company
В списке pgsql-hackers по дате отправления: