pgsql: Redesign parallel dump/restore's wait-for-workers logic. - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Redesign parallel dump/restore's wait-for-workers logic.
Date
Msg-id E1bow5d-0001qP-Sb@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Redesign parallel dump/restore's wait-for-workers logic.

The ListenToWorkers/ReapWorkerStatus APIs were messy and hard to use.
Instead, make DispatchJobForTocEntry register a callback function that
will take care of state cleanup, doing whatever had been done by the caller
of ReapWorkerStatus in the old design.  (This callback is essentially just
the old mark_work_done function in the restore case, and a trivial test for
worker failure in the dump case.)  Then we can have ListenToWorkers call
the callback immediately on receipt of a status message, and return the
worker to WRKR_IDLE state; so the WRKR_FINISHED state goes away.

This allows us to design a unified wait-for-worker-messages loop:
WaitForWorkers replaces EnsureIdleWorker and EnsureWorkersFinished as well
as the mess in restore_toc_entries_parallel.  Also, we no longer need the
fragile API spec that the caller of DispatchJobForTocEntry is responsible
for ensuring there's an idle worker, since DispatchJobForTocEntry can just
wait until there is one.

In passing, I got rid of the ParallelArgs struct, which was a net negative
in terms of notational verboseness, and didn't seem to be providing any
noticeable amount of abstraction either.

Tom Lane, reviewed by Kevin Grittner

Discussion: <1188.1464544443@sss.pgh.pa.us>

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/b7b8cc0cfcf1c956b752f3e25894f9ad607583b7

Modified Files
--------------
src/bin/pg_dump/parallel.c            | 228 ++++++++++++++++------------------
src/bin/pg_dump/parallel.h            |  72 +++++++----
src/bin/pg_dump/pg_backup_archiver.c  | 141 ++++++++++-----------
src/bin/pg_dump/pg_backup_archiver.h  |   3 +-
src/bin/pg_dump/pg_backup_custom.c    |   6 +-
src/bin/pg_dump/pg_backup_directory.c |   6 +-
6 files changed, 224 insertions(+), 232 deletions(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Improve contrib/cube's handling of zero-D cubes, infinities, and
Next
From: Tom Lane
Date:
Subject: pgsql: Rationalize parallel dump/restore's handling of worker cmd/statu