summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane2016-05-26 14:50:30 +0000
committerTom Lane2016-05-26 14:50:30 +0000
commitdf8d2d8c42c5731ad997793cb6a59b617532dffa (patch)
treef66baf774d474ed96cafc00cceaa66eaad909241 /src
parentb898eb63678d96482c1519c44f8ead073adf9bb7 (diff)
In Windows pg_dump, ensure idle workers will shut down during error exit.
The Windows coding of ShutdownWorkersHard() thought that setting termEvent was sufficient to make workers exit after an error. But that only helps if a worker is busy and passes through checkAborting(). An idle worker will just sit, resulting in pg_dump failing to exit until the user gives up and hits control-C. We should close the write end of the command pipe so that idle workers will see socket EOF and exit, as the Unix coding was already doing. Back-patch to 9.3 where parallel pg_dump was introduced. Kyotaro Horiguchi
Diffstat (limited to 'src')
-rw-r--r--src/bin/pg_dump/parallel.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/bin/pg_dump/parallel.c b/src/bin/pg_dump/parallel.c
index f650d3fef51..2f12a8689b4 100644
--- a/src/bin/pg_dump/parallel.c
+++ b/src/bin/pg_dump/parallel.c
@@ -300,28 +300,26 @@ checkAborting(ArchiveHandle *AH)
}
/*
- * Shut down any remaining workers, this has an implicit do_wait == true.
- *
- * The fastest way we can make the workers terminate gracefully is when
- * they are listening for new commands and we just tell them to terminate.
+ * Shut down any remaining workers, waiting for them to finish.
*/
static void
ShutdownWorkersHard(ParallelState *pstate)
{
-#ifndef WIN32
int i;
/*
- * Close our write end of the sockets so that the workers know they can
- * exit.
+ * Close our write end of the sockets so that any workers waiting for
+ * commands know they can exit.
*/
for (i = 0; i < pstate->numWorkers; i++)
closesocket(pstate->parallelSlot[i].pipeWrite);
+#ifndef WIN32
+ /* On non-Windows, send SIGTERM to abort commands-in-progress. */
for (i = 0; i < pstate->numWorkers; i++)
kill(pstate->parallelSlot[i].pid, SIGTERM);
#else
- /* The workers monitor this event via checkAborting(). */
+ /* Non-idle workers monitor this event via checkAborting(). */
SetEvent(termEvent);
#endif