|
PostgreSQL Source Code git master
|
#include "postgres_fe.h"#include <sys/select.h>#include <sys/wait.h>#include <signal.h>#include <unistd.h>#include <fcntl.h>#include "fe_utils/string_utils.h"#include "parallel.h"#include "pg_backup_utils.h"
Go to the source code of this file.
Data Structures | |
| struct | ParallelSlot |
| struct | ShutdownInformation |
| struct | DumpSignalInformation |
Macros | |
| #define | PIPE_READ 0 |
| #define | PIPE_WRITE 1 |
| #define | NO_SLOT (-1) /* Failure result for GetIdleWorker() */ |
| #define | WORKER_IS_RUNNING(workerStatus) ((workerStatus) == WRKR_IDLE || (workerStatus) == WRKR_WORKING) |
| #define | pgpipe(a) pipe(a) |
| #define | piperead(a, b, c) read(a,b,c) |
| #define | pipewrite(a, b, c) write(a,b,c) |
| #define | write_stderr(str) |
| #define | messageStartsWith(msg, prefix) (strncmp(msg, prefix, strlen(prefix)) == 0) |
Typedefs | |
| typedef struct ShutdownInformation | ShutdownInformation |
| typedef struct DumpSignalInformation | DumpSignalInformation |
Enumerations | |
| enum | T_WorkerStatus { WRKR_NOT_STARTED = 0 , WRKR_IDLE , WRKR_WORKING , WRKR_TERMINATED } |
Variables | |
| static ShutdownInformation | shutdown_info |
| static volatile DumpSignalInformation | signal_info |
Definition at line 228 of file parallel.c.
| #define NO_SLOT (-1) /* Failure result for GetIdleWorker() */ |
Definition at line 74 of file parallel.c.
Definition at line 139 of file parallel.c.
| #define PIPE_READ 0 |
Definition at line 71 of file parallel.c.
| #define PIPE_WRITE 1 |
Definition at line 72 of file parallel.c.
| #define WORKER_IS_RUNNING | ( | workerStatus | ) | ((workerStatus) == WRKR_IDLE || (workerStatus) == WRKR_WORKING) |
Definition at line 85 of file parallel.c.
Definition at line 186 of file parallel.c.
| Enumerator | |
|---|---|
| WRKR_NOT_STARTED | |
| WRKR_IDLE | |
| WRKR_WORKING | |
| WRKR_TERMINATED | |
Definition at line 77 of file parallel.c.
Definition at line 341 of file parallel.c.
References ParallelSlot::AH, arg, closesocket, DisconnectDatabase(), fb(), GetMyPSlot(), ParallelSlot::pipeRevRead, ParallelSlot::pipeRevWrite, _archiveHandle::public, and ShutdownWorkersHard().
Referenced by on_exit_close_archive().
|
static |
Definition at line 1108 of file parallel.c.
References ACT_DUMP, ACT_RESTORE, Assert, buf, _tocEntry::dumpId, fb(), and snprintf.
Referenced by DispatchJobForTocEntry().
|
static |
Definition at line 1156 of file parallel.c.
References buf, _tocEntry::dumpId, Archive::n_errors, _archiveHandle::public, snprintf, and WORKER_IGNORED_ERRORS.
Referenced by WaitForCommands().
| void DispatchJobForTocEntry | ( | ArchiveHandle * | AH, |
| ParallelState * | pstate, | ||
| TocEntry * | te, | ||
| T_Action | act, | ||
| ParallelCompletionPtr | callback, | ||
| void * | callback_data | ||
| ) |
Definition at line 1205 of file parallel.c.
References buf, buildWorkerCommand(), ParallelSlot::callback, callback(), ParallelSlot::callback_data, fb(), GetIdleWorker(), NO_SLOT, ParallelState::parallelSlot, sendMessageToWorker(), ParallelState::te, WaitForWorkers(), WFW_ONE_IDLE, ParallelSlot::workerStatus, and WRKR_WORKING.
Referenced by restore_toc_entries_parallel(), and WriteDataChunks().
|
static |
Definition at line 1236 of file parallel.c.
References i, NO_SLOT, ParallelState::numWorkers, ParallelState::parallelSlot, ParallelSlot::workerStatus, and WRKR_IDLE.
Referenced by DispatchJobForTocEntry(), and WaitForWorkers().
Definition at line 1516 of file parallel.c.
References fb(), PIPE_READ, and readMessageFromPipe().
Referenced by WaitForCommands().
|
static |
Definition at line 1579 of file parallel.c.
References Assert, do_wait, fb(), i, ParallelState::numWorkers, ParallelState::parallelSlot, pg_fatal, ParallelSlot::pipeRead, readMessageFromPipe(), select, select_loop(), WORKER_IS_RUNNING, and ParallelSlot::workerStatus.
Referenced by ListenToWorkers().
|
static |
Definition at line 266 of file parallel.c.
References fb(), i, ParallelState::numWorkers, ParallelState::parallelSlot, and ParallelSlot::pid.
Referenced by archive_close_connection().
|
static |
Definition at line 1252 of file parallel.c.
References i, ParallelState::numWorkers, ParallelState::parallelSlot, WORKER_IS_RUNNING, and ParallelSlot::workerStatus.
Referenced by WaitForTerminatingWorkers().
| bool IsEveryWorkerIdle | ( | ParallelState * | pstate | ) |
Definition at line 1268 of file parallel.c.
References i, ParallelState::numWorkers, ParallelState::parallelSlot, ParallelSlot::workerStatus, and WRKR_IDLE.
Referenced by ParallelBackupEnd(), restore_toc_entries_parallel(), and WaitForWorkers().
|
static |
Definition at line 1398 of file parallel.c.
References ParallelSlot::callback, ParallelSlot::callback_data, do_wait, fb(), free, getMessageFromWorker(), messageStartsWith, ParallelState::parallelSlot, parseWorkerResponse(), pg_fatal, ParallelState::te, ParallelSlot::workerStatus, and WRKR_IDLE.
Referenced by WaitForWorkers().
|
static |
Definition at line 1301 of file parallel.c.
References appendPQExpBuffer(), _archiveHandle::connection, createPQExpBuffer(), PQExpBufferData::data, _tocEntry::desc, destroyPQExpBuffer(), fb(), fmtQualifiedId(), pg_fatal, PGRES_COMMAND_OK, PQclear, PQexec(), PQresultStatus, and _tocEntry::tag.
Referenced by WaitForCommands().
Definition at line 330 of file parallel.c.
References ShutdownInformation::AHX, archive_close_connection(), on_exit_nicely(), and shutdown_info.
Referenced by main().
| void ParallelBackupEnd | ( | ArchiveHandle * | AH, |
| ParallelState * | pstate | ||
| ) |
Definition at line 1059 of file parallel.c.
References Assert, closesocket, fb(), free, i, IsEveryWorkerIdle(), ParallelState::numWorkers, ParallelState::parallelSlot, ParallelSlot::pipeRead, ParallelSlot::pipeWrite, ShutdownInformation::pstate, set_cancel_pstate(), shutdown_info, ParallelState::te, and WaitForTerminatingWorkers().
Referenced by _CloseArchive(), and RestoreArchive().
| ParallelState * ParallelBackupStart | ( | ArchiveHandle * | AH | ) |
Definition at line 895 of file parallel.c.
References DumpSignalInformation::am_worker, Assert, closesocket, _archiveHandle::connection, fb(), getLocalPQExpBuffer, i, j, ParallelState::numWorkers, Archive::numWorkers, ParallelState::parallelSlot, pg_fatal, pg_malloc0_array, pg_malloc_object, PG_SIG_IGN, pgpipe, ParallelSlot::pid, PIPE_READ, PIPE_WRITE, ParallelSlot::pipeRead, ParallelSlot::pipeRevRead, ParallelSlot::pipeRevWrite, ParallelSlot::pipeWrite, pqsignal, ShutdownInformation::pstate, _archiveHandle::public, RunWorker(), set_archive_cancel_info(), set_cancel_pstate(), shutdown_info, signal_info, SIGPIPE, ParallelState::te, ParallelSlot::workerStatus, and WRKR_IDLE.
Referenced by _CloseArchive(), and RestoreArchive().
|
static |
Definition at line 1123 of file parallel.c.
References ACT_DUMP, ACT_RESTORE, Assert, fb(), getTocEntryByDumpId(), messageStartsWith, and pg_fatal.
Referenced by WaitForCommands().
Definition at line 1171 of file parallel.c.
References Assert, _tocEntry::dumpId, fb(), messageStartsWith, Archive::n_errors, pg_fatal, and _archiveHandle::public.
Referenced by ListenToWorkers().
Definition at line 1662 of file parallel.c.
References Assert, bufsize, fb(), fd(), pg_free(), pg_malloc(), pg_realloc(), and piperead.
Referenced by getMessageFromLeader(), and getMessageFromWorker().
|
static |
Definition at line 827 of file parallel.c.
References CloneArchive(), DeCloneArchive(), DisconnectDatabase(), fb(), PIPE_READ, PIPE_WRITE, ParallelSlot::pipeRevRead, ParallelSlot::pipeRevWrite, _archiveHandle::public, set_cancel_slot_archive(), _archiveHandle::SetupWorkerPtr, and WaitForCommands().
Referenced by ParallelBackupStart().
Definition at line 1540 of file parallel.c.
References EINTR, fb(), i, and select.
Referenced by getMessageFromWorker().
Definition at line 1527 of file parallel.c.
References fb(), len, pg_fatal, PIPE_WRITE, pipewrite, and str.
Referenced by WaitForCommands().
Definition at line 1644 of file parallel.c.
References fb(), len, ParallelState::parallelSlot, pg_fatal, ParallelSlot::pipeWrite, pipewrite, and str.
Referenced by DispatchJobForTocEntry().
| void set_archive_cancel_info | ( | ArchiveHandle * | AH, |
| PGconn * | conn | ||
| ) |
Definition at line 728 of file parallel.c.
References conn, _archiveHandle::connCancel, fb(), DumpSignalInformation::myAH, PQfreeCancel(), PQgetCancel(), set_cancel_handler(), and signal_info.
Referenced by ConnectDatabaseAhx(), DisconnectDatabase(), and ParallelBackupStart().
Definition at line 611 of file parallel.c.
References fb(), DumpSignalInformation::handler_set, pqsignal, signal_info, SIGQUIT, and sigTermHandler().
Referenced by set_archive_cancel_info().
|
static |
Definition at line 787 of file parallel.c.
References fb(), DumpSignalInformation::pstate, and signal_info.
Referenced by ParallelBackupEnd(), and ParallelBackupStart().
|
static |
Definition at line 807 of file parallel.c.
References ParallelSlot::AH, and fb().
Referenced by RunWorker().
|
static |
Definition at line 397 of file parallel.c.
References ParallelSlot::AH, closesocket, _archiveHandle::connCancel, fb(), i, kill, ParallelState::numWorkers, ParallelState::parallelSlot, ParallelSlot::pid, ParallelSlot::pipeWrite, PQcancel(), and WaitForTerminatingWorkers().
Referenced by archive_close_connection().
|
static |
Definition at line 548 of file parallel.c.
References DumpSignalInformation::am_worker, _archiveHandle::connCancel, fb(), i, kill, DumpSignalInformation::myAH, ParallelState::numWorkers, ParallelState::parallelSlot, PG_SIG_IGN, ParallelSlot::pid, PQcancel(), pqsignal, progname, DumpSignalInformation::pstate, signal_info, SIGQUIT, and write_stderr.
Referenced by set_cancel_handler().
|
static |
Definition at line 1336 of file parallel.c.
References ACT_DUMP, ACT_RESTORE, Assert, buf, buildWorkerResponse(), fb(), free, getMessageFromLeader(), lockTableForWorker(), parseWorkerCommand(), sendMessageToLeader(), _archiveHandle::WorkerJobDumpPtr, and _archiveHandle::WorkerJobRestorePtr.
Referenced by RunWorker().
|
static |
Definition at line 448 of file parallel.c.
References Assert, fb(), HasEveryWorkerTerminated(), j, ParallelState::numWorkers, ParallelState::parallelSlot, pg_free(), pg_malloc_array, ParallelSlot::pid, ParallelState::te, WORKER_IS_RUNNING, ParallelSlot::workerStatus, and WRKR_TERMINATED.
Referenced by ParallelBackupEnd(), and ShutdownWorkersHard().
| void WaitForWorkers | ( | ArchiveHandle * | AH, |
| ParallelState * | pstate, | ||
| WFW_WaitOption | mode | ||
| ) |
Definition at line 1451 of file parallel.c.
References Assert, do_wait, GetIdleWorker(), IsEveryWorkerIdle(), ListenToWorkers(), mode, NO_SLOT, WFW_ALL_IDLE, WFW_GOT_STATUS, WFW_NO_WAIT, and WFW_ONE_IDLE.
Referenced by DispatchJobForTocEntry(), restore_toc_entries_parallel(), and WriteDataChunks().
|
static |
Definition at line 154 of file parallel.c.
Referenced by on_exit_close_archive(), ParallelBackupEnd(), and ParallelBackupStart().
|
static |
Definition at line 175 of file parallel.c.
Referenced by ParallelBackupStart(), set_archive_cancel_info(), set_cancel_handler(), set_cancel_pstate(), and sigTermHandler().