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"
#include "port/pg_bswap.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 |
#define messageStartsWith | ( | msg, | |
prefix | |||
) | (strncmp(msg, prefix, strlen(prefix)) == 0) |
Definition at line 226 of file parallel.c.
#define NO_SLOT (-1) /* Failure result for GetIdleWorker() */ |
Definition at line 72 of file parallel.c.
Definition at line 137 of file parallel.c.
#define PIPE_READ 0 |
Definition at line 69 of file parallel.c.
#define PIPE_WRITE 1 |
Definition at line 70 of file parallel.c.
#define WORKER_IS_RUNNING | ( | workerStatus | ) | ((workerStatus) == WRKR_IDLE || (workerStatus) == WRKR_WORKING) |
Definition at line 83 of file parallel.c.
#define write_stderr | ( | str | ) |
Definition at line 184 of file parallel.c.
typedef struct DumpSignalInformation DumpSignalInformation |
typedef struct ShutdownInformation ShutdownInformation |
enum T_WorkerStatus |
Enumerator | |
---|---|
WRKR_NOT_STARTED | |
WRKR_IDLE | |
WRKR_WORKING | |
WRKR_TERMINATED |
Definition at line 75 of file parallel.c.
|
static |
Definition at line 339 of file parallel.c.
References ParallelSlot::AH, ShutdownInformation::AHX, arg, closesocket, DisconnectDatabase(), GetMyPSlot(), ParallelSlot::pipeRevRead, ParallelSlot::pipeRevWrite, ShutdownInformation::pstate, _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, 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, 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().
|
static |
Definition at line 1516 of file parallel.c.
References PIPE_READ, and readMessageFromPipe().
Referenced by WaitForCommands().
|
static |
Definition at line 1579 of file parallel.c.
References Assert, do_wait, 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 264 of file parallel.c.
References 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().
void init_parallel_dump_utils | ( | void | ) |
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, 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(), fmtQualifiedId(), pg_fatal, PGRES_COMMAND_OK, PQclear(), PQexec(), PQresultStatus(), res, and _tocEntry::tag.
Referenced by WaitForCommands().
void on_exit_close_archive | ( | Archive * | AHX | ) |
Definition at line 328 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, 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 897 of file parallel.c.
References DumpSignalInformation::am_worker, Assert, closesocket, _archiveHandle::connection, exit(), fflush(), getLocalPQExpBuffer, i, j, ParallelState::numWorkers, Archive::numWorkers, ParallelState::parallelSlot, pg_fatal, pg_malloc(), pg_malloc0(), 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, SIG_IGN, 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, getTocEntryByDumpId(), messageStartsWith, and pg_fatal.
Referenced by WaitForCommands().
|
static |
Definition at line 1171 of file parallel.c.
References Assert, _tocEntry::dumpId, messageStartsWith, Archive::n_errors, pg_fatal, and _archiveHandle::public.
Referenced by ListenToWorkers().
|
static |
Definition at line 1662 of file parallel.c.
References Assert, bufsize, fd(), pg_free(), pg_malloc(), pg_realloc(), and piperead.
Referenced by getMessageFromLeader(), and getMessageFromWorker().
|
static |
Definition at line 829 of file parallel.c.
References CloneArchive(), DeCloneArchive(), DisconnectDatabase(), PIPE_READ, PIPE_WRITE, ParallelSlot::pipeRevRead, ParallelSlot::pipeRevWrite, _archiveHandle::public, set_cancel_slot_archive(), _archiveHandle::SetupWorkerPtr, and WaitForCommands().
Referenced by ParallelBackupStart().
|
static |
Definition at line 1540 of file parallel.c.
References EINTR, i, and select.
Referenced by getMessageFromWorker().
|
static |
Definition at line 1527 of file parallel.c.
References len, pg_fatal, PIPE_WRITE, pipewrite, and str.
Referenced by WaitForCommands().
|
static |
Definition at line 1644 of file parallel.c.
References 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 730 of file parallel.c.
References conn, _archiveHandle::connCancel, DumpSignalInformation::myAH, PQfreeCancel(), PQgetCancel(), set_cancel_handler(), and signal_info.
Referenced by ConnectDatabase(), DisconnectDatabase(), and ParallelBackupStart().
|
static |
Definition at line 608 of file parallel.c.
References DumpSignalInformation::handler_set, pqsignal(), signal_info, SIGQUIT, and sigTermHandler().
Referenced by set_archive_cancel_info().
|
static |
Definition at line 789 of file parallel.c.
References DumpSignalInformation::pstate, and signal_info.
Referenced by ParallelBackupEnd(), and ParallelBackupStart().
|
static |
|
static |
Definition at line 395 of file parallel.c.
References ParallelSlot::AH, closesocket, _archiveHandle::connCancel, i, kill, ParallelState::numWorkers, ParallelState::parallelSlot, ParallelSlot::pid, ParallelSlot::pipeWrite, PQcancel(), and WaitForTerminatingWorkers().
Referenced by archive_close_connection().
|
static |
Definition at line 545 of file parallel.c.
References DumpSignalInformation::am_worker, _archiveHandle::connCancel, i, kill, DumpSignalInformation::myAH, ParallelState::numWorkers, ParallelState::parallelSlot, ParallelSlot::pid, PQcancel(), pqsignal(), progname, DumpSignalInformation::pstate, SIG_IGN, 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(), free, getMessageFromLeader(), lockTableForWorker(), parseWorkerCommand(), sendMessageToLeader(), _archiveHandle::WorkerJobDumpPtr, and _archiveHandle::WorkerJobRestorePtr.
Referenced by RunWorker().
|
static |
Definition at line 446 of file parallel.c.
References Assert, free, HasEveryWorkerTerminated(), j, ParallelState::numWorkers, ParallelState::parallelSlot, pg_malloc(), 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 152 of file parallel.c.
Referenced by on_exit_close_archive(), ParallelBackupEnd(), and ParallelBackupStart().
|
static |
Definition at line 173 of file parallel.c.
Referenced by ParallelBackupStart(), set_archive_cancel_info(), set_cancel_handler(), set_cancel_pstate(), and sigTermHandler().