Re: Parallel Seq Scan - Mailing list pgsql-hackers

From Robert Haas
Subject Re: Parallel Seq Scan
Date
Msg-id CA+TgmoYksKPHi1dMfa0HcUgLNRoqCMF_goGiPK1MxgJakfq5Lg@mail.gmail.com
Whole thread Raw
In response to Re: Parallel Seq Scan  (Pavel Stehule <pavel.stehule@gmail.com>)
Responses Re: Parallel Seq Scan  (Pavel Stehule <pavel.stehule@gmail.com>)
Re: Parallel Seq Scan  (Thom Brown <thom@linux.com>)
Re: Parallel Seq Scan  (Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>)
List pgsql-hackers
On Wed, Nov 11, 2015 at 12:59 PM, Pavel Stehule <pavel.stehule@gmail.com> wrote:
> I have a first query
>
> I looked on EXPLAIN ANALYZE output and the numbers of filtered rows are
> differen

Hmm, I see I was right about people finding more bugs once this was
committed.  That didn't take long.

There's supposed to be code to handle this - see the
SharedPlanStateInstrumentation stuff in execParallel.c - but it's
evidently a few bricks shy of a load.
ExecParallelReportInstrumentation is supposed to transfer the counts
from each worker to the DSM:
       ps_instrument = &instrumentation->ps_instrument[i];       SpinLockAcquire(&ps_instrument->mutex);
InstrAggNode(&ps_instrument->instr,planstate->instrument);       SpinLockRelease(&ps_instrument->mutex);
 

And ExecParallelRetrieveInstrumentation is supposed to slurp those
counts back into the leader's PlanState objects:
       /* No need to acquire the spinlock here; workers have exited already. */       ps_instrument =
&instrumentation->ps_instrument[i];      InstrAggNode(planstate->instrument, &ps_instrument->instr);
 

This might be a race condition, or it might be just wrong logic.
Could you test what happens if you insert something like a 1-second
sleep in ExecParallelFinish just after the call to
WaitForParallelWorkersToFinish()?  If that makes the results
consistent, this is a race.  If it doesn't, something else is wrong:
then it would be useful to know whether the workers are actually
calling ExecParallelReportInstrumentation, and whether the leader is
actually calling ExecParallelRetrieveInstrumentation, and if so
whether they are doing it for the correct set of nodes.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Patch to install config/missing
Next
From: Pavel Stehule
Date:
Subject: Re: Parallel Seq Scan