|
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 355 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 1124 of file parallel.c.
References ACT_DUMP, ACT_RESTORE, Assert, buf, _tocEntry::dumpId, fb(), and snprintf.
Referenced by DispatchJobForTocEntry().
|
static |
Definition at line 1172 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 1221 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 1252 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 1532 of file parallel.c.
References fb(), PIPE_READ, and readMessageFromPipe().
Referenced by WaitForCommands().
|
static |
Definition at line 1595 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 1268 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 1284 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 1414 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 1317 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(), main(), restore_global_objects(), and restore_one_database().
| void ParallelBackupEnd | ( | ArchiveHandle * | AH, |
| ParallelState * | pstate | ||
| ) |
Definition at line 1075 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 913 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, 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 1139 of file parallel.c.
References ACT_DUMP, ACT_RESTORE, Assert, fb(), getTocEntryByDumpId(), messageStartsWith, and pg_fatal.
Referenced by WaitForCommands().
Definition at line 1187 of file parallel.c.
References Assert, _tocEntry::dumpId, fb(), messageStartsWith, Archive::n_errors, pg_fatal, and _archiveHandle::public.
Referenced by ListenToWorkers().
Definition at line 1678 of file parallel.c.
References Assert, bufsize, fb(), fd(), pg_free(), pg_malloc(), pg_realloc(), and piperead.
Referenced by getMessageFromLeader(), and getMessageFromWorker().
Definition at line 345 of file parallel.c.
References ShutdownInformation::AHX, and shutdown_info.
Referenced by restore_one_database().
|
static |
Definition at line 845 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 1556 of file parallel.c.
References EINTR, fb(), i, and select.
Referenced by getMessageFromWorker().
Definition at line 1543 of file parallel.c.
References fb(), len, pg_fatal, PIPE_WRITE, pipewrite, and str.
Referenced by WaitForCommands().
Definition at line 1660 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 746 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 624 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 805 of file parallel.c.
References fb(), DumpSignalInformation::pstate, and signal_info.
Referenced by ParallelBackupEnd(), and ParallelBackupStart().
|
static |
Definition at line 825 of file parallel.c.
References ParallelSlot::AH, and fb().
Referenced by RunWorker().
|
static |
Definition at line 411 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 561 of file parallel.c.
References DumpSignalInformation::am_worker, _archiveHandle::connCancel, fb(), i, kill, DumpSignalInformation::myAH, ParallelState::numWorkers, ParallelState::parallelSlot, ParallelSlot::pid, PQcancel(), pqsignal, progname, DumpSignalInformation::pstate, signal_info, SIGQUIT, and write_stderr.
Referenced by set_cancel_handler().
|
static |
Definition at line 1352 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 462 of file parallel.c.
References Assert, fb(), free, HasEveryWorkerTerminated(), j, ParallelState::numWorkers, ParallelState::parallelSlot, 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 1467 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(), ParallelBackupStart(), and replace_on_exit_close_archive().
|
static |
Definition at line 175 of file parallel.c.
Referenced by ParallelBackupStart(), set_archive_cancel_info(), set_cancel_handler(), set_cancel_pstate(), and sigTermHandler().