Commit 6b3094c2 authored by Tom Lane's avatar Tom Lane

Lots of comment-fixing, and minor cosmetic cleanup, in pg_dump/parallel.c.

The commentary in this file was in extremely sad shape.  The author(s)
had clearly never heard of the project convention that a function header
comment should provide an API spec of some sort for that function.  Much
of it was flat out wrong, too --- maybe it was accurate when written, but
if so it had not been updated to track subsequent code revisions.  Rewrite
and rearrange to try to bring it up to speed, and annotate some of the
places where more work is needed.  (I've refrained from actually fixing
anything of substance ... yet.)

Also, rename a couple of functions for more clarity as to what they do,
do some very minor code rearrangement, remove some pointless Asserts,
fix an incorrect Assert in readMessageFromPipe, and add a missing socket
close in one error exit from pgpipe().  The last would be a bug if we
tried to continue after pgpipe() failure, but since we don't, it's just
cosmetic at present.

Although this is only cosmetic, back-patch to 9.3 where parallel.c was
added.  It's sufficiently invasive that it'll pose a hazard for future
back-patching if we don't.

Discussion: <25239.1464386067@sss.pgh.pa.us>
parent 807b4537
This diff is collapsed.
...@@ -2326,6 +2326,9 @@ _allocAH(const char *FileSpec, const ArchiveFormat fmt, ...@@ -2326,6 +2326,9 @@ _allocAH(const char *FileSpec, const ArchiveFormat fmt,
return AH; return AH;
} }
/*
* Write out all data (tables & blobs)
*/
void void
WriteDataChunks(ArchiveHandle *AH, ParallelState *pstate) WriteDataChunks(ArchiveHandle *AH, ParallelState *pstate)
{ {
...@@ -2343,15 +2346,18 @@ WriteDataChunks(ArchiveHandle *AH, ParallelState *pstate) ...@@ -2343,15 +2346,18 @@ WriteDataChunks(ArchiveHandle *AH, ParallelState *pstate)
{ {
/* /*
* If we are in a parallel backup, then we are always the master * If we are in a parallel backup, then we are always the master
* process. * process. Dispatch each data-transfer job to a worker.
*/ */
EnsureIdleWorker(AH, pstate); EnsureIdleWorker(AH, pstate);
Assert(GetIdleWorker(pstate) != NO_SLOT);
DispatchJobForTocEntry(AH, pstate, te, ACT_DUMP); DispatchJobForTocEntry(AH, pstate, te, ACT_DUMP);
} }
else else
WriteDataChunksForTocEntry(AH, te); WriteDataChunksForTocEntry(AH, te);
} }
/*
* If parallel, wait for workers to finish.
*/
EnsureWorkersFinished(AH, pstate); EnsureWorkersFinished(AH, pstate);
} }
...@@ -3819,13 +3825,11 @@ restore_toc_entries_parallel(ArchiveHandle *AH, ParallelState *pstate, ...@@ -3819,13 +3825,11 @@ restore_toc_entries_parallel(ArchiveHandle *AH, ParallelState *pstate,
par_list_remove(next_work_item); par_list_remove(next_work_item);
Assert(GetIdleWorker(pstate) != NO_SLOT);
DispatchJobForTocEntry(AH, pstate, next_work_item, ACT_RESTORE); DispatchJobForTocEntry(AH, pstate, next_work_item, ACT_RESTORE);
} }
else else
{ {
/* at least one child is working and we have nothing ready. */ /* at least one child is working and we have nothing ready. */
Assert(!IsEveryWorkerIdle(pstate));
} }
for (;;) for (;;)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment