PostgreSQL Source Code
git master
|
#include "postgres_fe.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 228 of file parallel.c.
Referenced by ListenToWorkers(), parseWorkerCommand(), and parseWorkerResponse().
#define NO_SLOT (-1) /* Failure result for GetIdleWorker() */ |
Definition at line 74 of file parallel.c.
Referenced by DispatchJobForTocEntry(), GetIdleWorker(), and WaitForWorkers().
#define pgpipe | ( | a | ) | pipe(a) |
Definition at line 139 of file parallel.c.
Referenced by ParallelBackupStart(), and readMessageFromPipe().
#define PIPE_READ 0 |
Definition at line 71 of file parallel.c.
Referenced by getMessageFromLeader(), ParallelBackupStart(), and RunWorker().
#define PIPE_WRITE 1 |
Definition at line 72 of file parallel.c.
Referenced by ParallelBackupStart(), RunWorker(), and sendMessageToLeader().
Definition at line 140 of file parallel.c.
Referenced by readMessageFromPipe().
Definition at line 141 of file parallel.c.
Referenced by sendMessageToLeader(), and sendMessageToWorker().
#define WORKER_IS_RUNNING | ( | workerStatus | ) | ((workerStatus) == WRKR_IDLE || (workerStatus) == WRKR_WORKING) |
Definition at line 85 of file parallel.c.
Referenced by getMessageFromWorker(), HasEveryWorkerTerminated(), and WaitForTerminatingWorkers().
#define write_stderr | ( | str | ) |
Definition at line 186 of file parallel.c.
Referenced by AuxiliaryProcessMain(), check_root(), checkControlFile(), crashDumpHandler(), ExceptionalCondition(), pg_attribute_printf(), pg_signal_thread(), PostmasterMain(), PostmasterMarkPIDForWorkerNotify(), printMixedStruct(), save_ps_display_args(), SelectConfigFiles(), SetMessageEncoding(), setup_cancel_handler(), sigTermHandler(), startup_hacks(), and write_syslogger_file().
typedef struct DumpSignalInformation DumpSignalInformation |
typedef struct ShutdownInformation ShutdownInformation |
enum T_WorkerStatus |
Enumerator | |
---|---|
WRKR_NOT_STARTED | |
WRKR_IDLE | |
WRKR_WORKING | |
WRKR_TERMINATED |
Definition at line 77 of file parallel.c.
|
static |
Definition at line 344 of file parallel.c.
References ParallelSlot::AH, ShutdownInformation::AHX, closesocket, DisconnectDatabase(), GetMyPSlot(), ParallelSlot::pipeRevRead, ParallelSlot::pipeRevWrite, ShutdownInformation::pstate, _archiveHandle::public, and ShutdownWorkersHard().
Referenced by on_exit_close_archive().
|
static |
Definition at line 1113 of file parallel.c.
References ACT_DUMP, ACT_RESTORE, Assert, _tocEntry::dumpId, and snprintf.
Referenced by DispatchJobForTocEntry().
|
static |
Definition at line 1161 of file parallel.c.
References _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 1210 of file parallel.c.
References buf, buildWorkerCommand(), ParallelSlot::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 1241 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 1521 of file parallel.c.
References PIPE_READ, and readMessageFromPipe().
Referenced by WaitForCommands().
|
static |
Definition at line 1584 of file parallel.c.
References Assert, fatal, i, ParallelState::numWorkers, ParallelState::parallelSlot, ParallelSlot::pipeRead, readMessageFromPipe(), select, select_loop(), WORKER_IS_RUNNING, and ParallelSlot::workerStatus.
Referenced by ListenToWorkers().
|
static |
Definition at line 269 of file parallel.c.
References createPQExpBuffer(), i, ParallelState::numWorkers, ParallelState::parallelSlot, ParallelSlot::pid, and resetPQExpBuffer().
Referenced by archive_close_connection().
|
static |
Definition at line 1257 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 | ) |
Definition at line 238 of file parallel.c.
References exit_nicely, and pg_log_error.
Referenced by main().
bool IsEveryWorkerIdle | ( | ParallelState * | pstate | ) |
Definition at line 1273 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 1403 of file parallel.c.
References ParallelSlot::callback, ParallelSlot::callback_data, fatal, free, getMessageFromWorker(), messageStartsWith, ParallelState::parallelSlot, parseWorkerResponse(), status(), ParallelState::te, ParallelSlot::workerStatus, and WRKR_IDLE.
Referenced by WaitForWorkers().
|
static |
Definition at line 1306 of file parallel.c.
References appendPQExpBuffer(), _archiveHandle::connection, createPQExpBuffer(), PQExpBufferData::data, _tocEntry::desc, destroyPQExpBuffer(), fatal, fmtQualifiedId(), PGRES_COMMAND_OK, PQclear(), PQexec(), PQresultStatus(), and _tocEntry::tag.
Referenced by WaitForCommands().
void on_exit_close_archive | ( | Archive * | AHX | ) |
Definition at line 333 of file parallel.c.
References ShutdownInformation::AHX, archive_close_connection(), and on_exit_nicely().
Referenced by main().
void ParallelBackupEnd | ( | ArchiveHandle * | AH, |
ParallelState * | pstate | ||
) |
Definition at line 1064 of file parallel.c.
References Assert, closesocket, free, i, IsEveryWorkerIdle(), ParallelState::numWorkers, ParallelState::parallelSlot, ParallelSlot::pipeRead, ParallelSlot::pipeWrite, ShutdownInformation::pstate, set_cancel_pstate(), ParallelState::te, and WaitForTerminatingWorkers().
Referenced by _CloseArchive(), and RestoreArchive().
ParallelState* ParallelBackupStart | ( | ArchiveHandle * | AH | ) |
Definition at line 902 of file parallel.c.
References ParallelSlot::AH, DumpSignalInformation::am_worker, Assert, closesocket, _archiveHandle::connection, fatal, getLocalPQExpBuffer, i, ParallelState::numWorkers, Archive::numWorkers, ParallelState::parallelSlot, 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(), SIG_IGN, SIGPIPE, ParallelState::te, ParallelSlot::workerStatus, and WRKR_IDLE.
Referenced by _CloseArchive(), and RestoreArchive().
|
static |
Definition at line 1128 of file parallel.c.
References ACT_DUMP, ACT_RESTORE, Assert, fatal, getTocEntryByDumpId(), and messageStartsWith.
Referenced by WaitForCommands().
|
static |
Definition at line 1176 of file parallel.c.
References Assert, _tocEntry::dumpId, fatal, messageStartsWith, Archive::n_errors, _archiveHandle::public, and status().
Referenced by ListenToWorkers().
|
static |
Definition at line 1667 of file parallel.c.
References accept, Assert, bind, closesocket, connect, listen, pg_free(), pg_hton16, pg_hton32, pg_log_error, pg_malloc(), pg_realloc(), PGINVALID_SOCKET, pgpipe, piperead, and socket.
Referenced by getMessageFromLeader(), and getMessageFromWorker().
|
static |
Definition at line 834 of file parallel.c.
References ParallelSlot::AH, CloneArchive(), DeCloneArchive(), DisconnectDatabase(), free, 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 1545 of file parallel.c.
References EINTR, i, and select.
Referenced by getMessageFromWorker().
|
static |
Definition at line 1532 of file parallel.c.
References fatal, PIPE_WRITE, and pipewrite.
Referenced by WaitForCommands().
|
static |
Definition at line 1649 of file parallel.c.
References fatal, ParallelState::parallelSlot, ParallelSlot::pipeWrite, and pipewrite.
Referenced by DispatchJobForTocEntry().
void set_archive_cancel_info | ( | ArchiveHandle * | AH, |
PGconn * | conn | ||
) |
Definition at line 735 of file parallel.c.
References ParallelSlot::AH, _archiveHandle::connCancel, DumpSignalInformation::myAH, PQfreeCancel(), PQgetCancel(), and setup_cancel_handler().
Referenced by ConnectDatabase(), DisconnectDatabase(), and ParallelBackupStart().
|
static |
Definition at line 794 of file parallel.c.
References DumpSignalInformation::pstate.
Referenced by ParallelBackupEnd(), and ParallelBackupStart().
|
static |
|
static |
Definition at line 613 of file parallel.c.
References ParallelSlot::AH, _archiveHandle::connCancel, DumpSignalInformation::handler_set, i, DumpSignalInformation::myAH, ParallelState::numWorkers, ParallelState::parallelSlot, PQcancel(), pqsignal(), progname, DumpSignalInformation::pstate, SIGQUIT, sigTermHandler(), and write_stderr.
Referenced by main(), psql_setup_cancel_handler(), runInitSteps(), and set_archive_cancel_info().
|
static |
Definition at line 400 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 550 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, SIGQUIT, and write_stderr.
Referenced by setup_cancel_handler().
|
static |
Definition at line 1341 of file parallel.c.
References ACT_DUMP, ACT_RESTORE, Assert, buf, buildWorkerResponse(), free, getMessageFromLeader(), lockTableForWorker(), parseWorkerCommand(), sendMessageToLeader(), status(), _archiveHandle::WorkerJobDumpPtr, and _archiveHandle::WorkerJobRestorePtr.
Referenced by RunWorker().
|
static |
Definition at line 451 of file parallel.c.
References Assert, free, HasEveryWorkerTerminated(), ParallelState::numWorkers, ParallelState::parallelSlot, pg_malloc(), ParallelSlot::pid, status(), 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 1456 of file parallel.c.
References Assert, do_wait, GetIdleWorker(), IsEveryWorkerIdle(), ListenToWorkers(), 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.
|
static |
Definition at line 175 of file parallel.c.