PostgreSQL Source Code
git master
|
#include "postgres_fe.h"
#include <ctype.h>
#include <dirent.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <signal.h>
#include <sys/time.h>
#include "access/xlog_internal.h"
#include "pg_getopt.h"
Go to the source code of this file.
Macros | |
#define | NoFailover 0 |
#define | SmartFailover 1 |
#define | FastFailover 2 |
#define | RESTORE_COMMAND_COPY 0 |
#define | RESTORE_COMMAND_LINK 1 |
#define | XLOG_DATA 0 |
#define | XLOG_HISTORY 1 |
#define | SET_RESTORE_COMMAND(cmd, arg1, arg2) snprintf(restoreCommand, MAXPGPATH, cmd " \"%s\" \"%s\"", arg1, arg2) |
Functions | |
static bool | SetWALFileNameForCleanup (void) |
static bool | SetWALSegSize (void) |
static void | CustomizableInitialize (void) |
static bool | CustomizableNextWALFileReady (void) |
static void | CustomizableCleanupPriorWALFiles (void) |
static void | CheckForExternalTrigger (void) |
static bool | RestoreWALFileForRecovery (void) |
static void | usage (void) |
static void | sighandler (int sig) |
static void | sigquit_handler (int sig) |
int | main (int argc, char **argv) |
Variables | |
const char * | progname |
int | WalSegSz = -1 |
int | sleeptime = 5 |
int | waittime = -1 |
int | maxwaittime = 0 |
int | keepfiles = 0 |
int | maxretries = 3 |
bool | debug = false |
bool | need_cleanup = false |
static volatile sig_atomic_t | signaled = false |
char * | archiveLocation |
char * | triggerPath |
char * | xlogFilePath |
char * | nextWALFileName |
char * | restartWALFileName |
char | WALFilePath [MAXPGPATH *2] |
char | restoreCommand [MAXPGPATH] |
char | exclusiveCleanupFileName [MAXFNAMELEN] |
static int | Failover = NoFailover |
int | restoreCommandType |
int | nextWALFileType |
struct stat | stat_buf |
#define FastFailover 2 |
Definition at line 85 of file pg_standby.c.
Referenced by CheckForExternalTrigger(), and main().
#define NoFailover 0 |
Definition at line 83 of file pg_standby.c.
#define RESTORE_COMMAND_COPY 0 |
Definition at line 89 of file pg_standby.c.
Referenced by CustomizableInitialize(), and main().
#define RESTORE_COMMAND_LINK 1 |
Definition at line 90 of file pg_standby.c.
Referenced by CustomizableInitialize(), and main().
#define SET_RESTORE_COMMAND | ( | cmd, | |
arg1, | |||
arg2 | |||
) | snprintf(restoreCommand, MAXPGPATH, cmd " \"%s\" \"%s\"", arg1, arg2) |
Definition at line 97 of file pg_standby.c.
Referenced by CustomizableInitialize().
#define SmartFailover 1 |
Definition at line 84 of file pg_standby.c.
Referenced by CheckForExternalTrigger(), and main().
#define XLOG_DATA 0 |
Definition at line 93 of file pg_standby.c.
Referenced by CustomizableCleanupPriorWALFiles(), and CustomizableNextWALFileReady().
#define XLOG_HISTORY 1 |
Definition at line 94 of file pg_standby.c.
Referenced by main().
|
static |
Definition at line 462 of file pg_standby.c.
References buf, close, Failover, FastFailover, fd(), fprintf, ftruncate, read, SmartFailover, stat::st_size, stat, stat_buf, strerror, and triggerPath.
Referenced by main().
|
static |
Definition at line 246 of file pg_standby.c.
References archiveLocation, closedir(), dirent::d_name, debug, exclusiveCleanupFileName, fprintf, IsXLogFileName, nextWALFileType, opendir(), progname, readdir(), snprintf, strerror, WALFilePath, and XLOG_DATA.
Referenced by main().
|
static |
Definition at line 128 of file pg_standby.c.
References archiveLocation, fprintf, MAXPGPATH, nextWALFileName, progname, RESTORE_COMMAND_COPY, RESTORE_COMMAND_LINK, restoreCommandType, SET_RESTORE_COMMAND, snprintf, stat, stat_buf, WALFilePath, and xlogFilePath.
Referenced by main().
|
static |
Definition at line 175 of file pg_standby.c.
References _, debug, exclusiveCleanupFileName, fprintf, IsXLogFileName, need_cleanup, nextWALFileName, nextWALFileType, pg_usleep(), SetWALFileNameForCleanup(), SetWALSegSize(), sleeptime, stat::st_size, stat, stat_buf, WALFilePath, WalSegSz, and XLOG_DATA.
Referenced by main().
int main | ( | int | argc, |
char ** | argv | ||
) |
Definition at line 635 of file pg_standby.c.
References archiveLocation, CheckForExternalTrigger(), CustomizableCleanupPriorWALFiles(), CustomizableInitialize(), CustomizableNextWALFileReady(), debug, Failover, FastFailover, fprintf, get_progname(), getopt(), IsTLHistoryFileName, keepfiles, maxretries, maxwaittime, need_cleanup, nextWALFileName, nextWALFileType, optarg, optind, pg_strdup(), pg_usleep(), pqsignal(), progname, restartWALFileName, RESTORE_COMMAND_COPY, RESTORE_COMMAND_LINK, restoreCommand, restoreCommandType, RestoreWALFileForRecovery(), sighandler(), signaled, SIGQUIT, sigquit_handler(), SIGUSR1, sleeptime, SmartFailover, triggerPath, usage(), waittime, WALFilePath, XLOG_HISTORY, and xlogFilePath.
|
static |
Definition at line 554 of file pg_standby.c.
References debug, fprintf, maxretries, pg_usleep(), restoreCommand, and sleeptime.
Referenced by main().
|
static |
Definition at line 332 of file pg_standby.c.
References cleanup(), exclusiveCleanupFileName, keepfiles, nextWALFileName, restartWALFileName, strlcpy(), WalSegSz, and XLogFileNameById.
Referenced by CustomizableNextWALFileReady().
|
static |
Definition at line 396 of file pg_standby.c.
References Assert, buf, close, PGAlignedXLogBlock::data, debug, fd(), fprintf, IsValidWalSegSize, progname, read, strerror, WALFilePath, WalSegSz, and XLogLongPageHeaderData::xlp_seg_size.
Referenced by CustomizableNextWALFileReady().
|
static |
|
static |
Definition at line 626 of file pg_standby.c.
References kill, pqsignal(), and SIG_DFL.
Referenced by main().
|
static |
Definition at line 589 of file pg_standby.c.
References printf, and progname.
Referenced by exec_command_slash_command_help(), main(), parse_psql_options(), and pg_notification_queue_usage().
char* archiveLocation |
Definition at line 55 of file pg_standby.c.
Referenced by CustomizableCleanupPriorWALFiles(), CustomizableInitialize(), and main().
Definition at line 47 of file pg_standby.c.
Referenced by CustomizableCleanupPriorWALFiles(), CustomizableNextWALFileReady(), len_utf8(), main(), pg_regcomp(), RestoreWALFileForRecovery(), SetWALSegSize(), and slice_check().
char exclusiveCleanupFileName[MAXFNAMELEN] |
Definition at line 62 of file pg_standby.c.
Referenced by CustomizableCleanupPriorWALFiles(), CustomizableNextWALFileReady(), and SetWALFileNameForCleanup().
|
static |
Definition at line 87 of file pg_standby.c.
Referenced by CheckForExternalTrigger(), and main().
int keepfiles = 0 |
Definition at line 45 of file pg_standby.c.
Referenced by main(), and SetWALFileNameForCleanup().
int maxretries = 3 |
Definition at line 46 of file pg_standby.c.
Referenced by main(), and RestoreWALFileForRecovery().
int maxwaittime = 0 |
Definition at line 44 of file pg_standby.c.
Referenced by main().
Definition at line 48 of file pg_standby.c.
Referenced by CustomizableNextWALFileReady(), and main().
char* nextWALFileName |
Definition at line 58 of file pg_standby.c.
Referenced by CustomizableInitialize(), CustomizableNextWALFileReady(), main(), and SetWALFileNameForCleanup().
int nextWALFileType |
Definition at line 95 of file pg_standby.c.
Referenced by CustomizableCleanupPriorWALFiles(), CustomizableNextWALFileReady(), and main().
const char* progname |
Definition at line 36 of file pg_standby.c.
Referenced by _check_database_version(), AuxiliaryProcessMain(), checkControlFile(), connectDatabase(), ConnectDatabase(), CustomizableCleanupPriorWALFiles(), CustomizableInitialize(), get_progname(), main(), PostgresMain(), PostmasterMain(), process_postgres_switches(), setup_cancel_handler(), SetWALSegSize(), sigTermHandler(), and usage().
char* restartWALFileName |
Definition at line 59 of file pg_standby.c.
Referenced by main(), and SetWALFileNameForCleanup().
char restoreCommand[MAXPGPATH] |
Definition at line 61 of file pg_standby.c.
Referenced by main(), and RestoreWALFileForRecovery().
int restoreCommandType |
Definition at line 91 of file pg_standby.c.
Referenced by CustomizableInitialize(), and main().
|
static |
Definition at line 52 of file pg_standby.c.
Referenced by ConditionVariableCancelSleep(), main(), sighandler(), and SignalSomeChildren().
int sleeptime = 5 |
Definition at line 41 of file pg_standby.c.
Referenced by CalculateCopyStreamSleeptime(), CustomizableNextWALFileReady(), HandleCopyStream(), main(), RestoreWALFileForRecovery(), WalSndComputeSleeptime(), WalSndLoop(), WalSndWaitForWal(), and WalSndWriteData().
struct stat stat_buf |
Definition at line 100 of file pg_standby.c.
Referenced by CheckForExternalTrigger(), CustomizableInitialize(), and CustomizableNextWALFileReady().
char* triggerPath |
Definition at line 56 of file pg_standby.c.
Referenced by CheckForExternalTrigger(), and main().
int waittime = -1 |
Definition at line 42 of file pg_standby.c.
Referenced by AutoVacLauncherMain(), main(), and pg_timer_thread().
char WALFilePath[MAXPGPATH *2] |
Definition at line 60 of file pg_standby.c.
Referenced by CleanupPriorWALFiles(), CustomizableCleanupPriorWALFiles(), CustomizableInitialize(), CustomizableNextWALFileReady(), main(), and SetWALSegSize().
int WalSegSz = -1 |
Definition at line 38 of file pg_standby.c.
Referenced by AuxiliaryProcessMain(), close_walfile(), CustomizableNextWALFileReady(), extractPageMap(), findLastCheckpoint(), FindStreamingStart(), main(), open_walfile(), ProcessXLogDataMsg(), readOneRecord(), ReceiveXlogStream(), SetWALFileNameForCleanup(), SetWALSegSize(), SimpleXLogPageRead(), StartLogStreamer(), and StreamLog().
char* xlogFilePath |
Definition at line 57 of file pg_standby.c.
Referenced by CustomizableInitialize(), and main().