1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-28 23:42:10 +03:00

Add new function WaitForParallelWorkersToAttach.

Once this function has been called, we know that all workers have
started and attached to their error queues -- so if any of them
subsequently exit uncleanly, we'll be sure to throw an ERROR promptly.
Otherwise, users of the ParallelContext machinery must be careful not
to wait forever for a worker that has failed to start.  Parallel query
manages to work without needing this for reasons explained in new
comments added by this patch, but it's a useful primitive for other
parallel operations, such as the pending patch to make creating a
btree index run in parallel.

Amit Kapila, revised by me.  Additional review by Peter Geoghegan.

Discussion: http://postgr.es/m/CAA4eK1+e2MzyouF5bg=OtyhDSX+=Ao=3htN=T-r_6s3gCtKFiw@mail.gmail.com
This commit is contained in:
Robert Haas
2018-02-02 09:00:59 -05:00
parent a2a2205761
commit 9222c0d9ed
4 changed files with 163 additions and 11 deletions

View File

@ -312,7 +312,14 @@ gather_readnext(GatherState *gatherstate)
/* Check for async events, particularly messages from workers. */
CHECK_FOR_INTERRUPTS();
/* Attempt to read a tuple, but don't block if none is available. */
/*
* Attempt to read a tuple, but don't block if none is available.
*
* Note that TupleQueueReaderNext will just return NULL for a worker
* which fails to initialize. We'll treat that worker as having
* produced no tuples; WaitForParallelWorkersToFinish will error out
* when we get there.
*/
Assert(gatherstate->nextreader < gatherstate->nreaders);
reader = gatherstate->reader[gatherstate->nextreader];
tup = TupleQueueReaderNext(reader, true, &readerdone);