PostgreSQL Source Code
git master
|
#include "postgres.h"
#include <time.h>
#include <sys/stat.h>
#include <unistd.h>
#include "access/xlog.h"
#include "access/xlog_internal.h"
#include "archive/archive_module.h"
#include "archive/shell_archive.h"
#include "lib/binaryheap.h"
#include "libpq/pqsignal.h"
#include "pgstat.h"
#include "postmaster/interrupt.h"
#include "postmaster/pgarch.h"
#include "storage/fd.h"
#include "storage/ipc.h"
#include "storage/latch.h"
#include "storage/pmsignal.h"
#include "storage/proc.h"
#include "storage/procsignal.h"
#include "storage/shmem.h"
#include "storage/spin.h"
#include "utils/guc.h"
#include "utils/memutils.h"
#include "utils/ps_status.h"
Go to the source code of this file.
Data Structures | |
struct | PgArchData |
struct | arch_files_state |
Macros | |
#define | PGARCH_AUTOWAKE_INTERVAL |
#define | PGARCH_RESTART_INTERVAL |
#define | NUM_ARCHIVE_RETRIES 3 |
#define | NUM_ORPHAN_CLEANUP_RETRIES 3 |
#define | NUM_FILES_PER_DIRECTORY_SCAN 64 |
Typedefs | |
typedef struct PgArchData | PgArchData |
Functions | |
static void | pgarch_waken_stop (SIGNAL_ARGS) |
static void | pgarch_MainLoop (void) |
static void | pgarch_ArchiverCopyLoop (void) |
static bool | pgarch_archiveXlog (char *xlog) |
static bool | pgarch_readyXlog (char *xlog) |
static void | pgarch_archiveDone (char *xlog) |
static void | pgarch_die (int code, Datum arg) |
static void | HandlePgArchInterrupts (void) |
static int | ready_file_comparator (Datum a, Datum b, void *arg) |
static void | LoadArchiveLibrary (void) |
static void | pgarch_call_module_shutdown_cb (int code, Datum arg) |
Size | PgArchShmemSize (void) |
void | PgArchShmemInit (void) |
bool | PgArchCanRestart (void) |
void | PgArchiverMain (void) |
void | PgArchWakeup (void) |
void | PgArchForceDirScan (void) |
Variables | |
char * | XLogArchiveLibrary = "" |
static time_t | last_sigterm_time = 0 |
static PgArchData * | PgArch = NULL |
static const ArchiveModuleCallbacks * | ArchiveCallbacks |
static ArchiveModuleState * | archive_module_state |
static struct arch_files_state * | arch_files = NULL |
static volatile sig_atomic_t | ready_to_stop = false |
#define PGARCH_AUTOWAKE_INTERVAL |
#define PGARCH_RESTART_INTERVAL |
typedef struct PgArchData PgArchData |
|
static |
Definition at line 769 of file pgarch.c.
References ConfigReloadPending, ereport, errcode(), errdetail(), errmsg(), ERROR, LOG, LogMemoryContextPending, pfree(), PGC_SIGHUP, proc_exit(), ProcessConfigFile(), ProcessLogMemoryContextInterrupt(), ProcessProcSignalBarrier(), ProcSignalBarrierPending, pstrdup(), XLogArchiveCommand, and XLogArchiveLibrary.
Referenced by pgarch_ArchiverCopyLoop(), and pgarch_MainLoop().
|
static |
Definition at line 821 of file pgarch.c.
References ArchiveModuleCallbacks::archive_file_cb, archive_module_state, ArchiveCallbacks, before_shmem_exit(), ereport, errcode(), errdetail(), errmsg(), ERROR, load_external_function(), palloc0(), pgarch_call_module_shutdown_cb(), shell_archive_init(), ArchiveModuleCallbacks::startup_cb, XLogArchiveCommand, and XLogArchiveLibrary.
Referenced by PgArchiverMain().
|
static |
Definition at line 726 of file pgarch.c.
References ereport, errcode_for_file_access(), errmsg(), MAXPGPATH, StatusFilePath(), and WARNING.
Referenced by pgarch_ArchiverCopyLoop().
|
static |
Definition at line 369 of file pgarch.c.
References arch_files, arch_files_state::arch_files_size, archive_module_state, ArchiveCallbacks, ArchiveModuleCallbacks::check_configured_cb, ereport, errmsg(), HandlePgArchInterrupts(), MAX_XFN_CHARS, MAXPGPATH, NUM_ARCHIVE_RETRIES, NUM_ORPHAN_CLEANUP_RETRIES, pg_usleep(), pgarch_archiveDone(), pgarch_archiveXlog(), pgarch_readyXlog(), pgstat_report_archiver(), PostmasterIsAlive, ShutdownRequestPending, snprintf, stat, StatusFilePath(), WARNING, and XLOGDIR.
Referenced by pgarch_MainLoop().
|
static |
Definition at line 500 of file pgarch.c.
References ArchiveModuleCallbacks::archive_file_cb, archive_module_state, ArchiveCallbacks, MAXFNAMELEN, MAXPGPATH, set_ps_display(), snprintf, and XLOGDIR.
Referenced by pgarch_ArchiverCopyLoop().
|
static |
Definition at line 863 of file pgarch.c.
References archive_module_state, ArchiveCallbacks, and ArchiveModuleCallbacks::shutdown_cb.
Referenced by LoadArchiveLibrary().
|
static |
Definition at line 755 of file pgarch.c.
References INVALID_PGPROCNO, PgArch, and PgArchData::pgprocno.
Referenced by PgArchiverMain().
|
static |
Definition at line 299 of file pgarch.c.
References HandlePgArchInterrupts(), last_sigterm_time, MyLatch, pgarch_ArchiverCopyLoop(), PGARCH_AUTOWAKE_INTERVAL, ready_to_stop, ResetLatch(), ShutdownRequestPending, time_to_stop, WaitLatch(), WL_LATCH_SET, WL_POSTMASTER_DEATH, and WL_TIMEOUT.
Referenced by PgArchiverMain().
|
static |
Definition at line 545 of file pgarch.c.
References AllocateDir(), arch_files_state::arch_filenames, arch_files_state::arch_files, arch_files, arch_files_state::arch_files_size, arch_files_state::arch_heap, PgArchData::arch_lck, binaryheap::bh_size, binaryheap_add(), binaryheap_add_unordered(), binaryheap_build(), binaryheap_first(), binaryheap_remove_first(), binaryheap_reset(), CStringGetDatum(), dirent::d_name, DatumGetCString(), ereport, errcode_for_file_access(), errmsg(), ERROR, PgArchData::force_dir_scan, FreeDir(), i, MAX_XFN_CHARS, MAXPGPATH, MIN_XFN_CHARS, NUM_FILES_PER_DIRECTORY_SCAN, PgArch, ReadDir(), ready_file_comparator(), snprintf, SpinLockAcquire, SpinLockRelease, stat, StatusFilePath(), VALID_XFN_CHARS, and XLOGDIR.
Referenced by pgarch_ArchiverCopyLoop().
|
static |
Definition at line 282 of file pgarch.c.
References MyLatch, ready_to_stop, and SetLatch().
Referenced by PgArchiverMain().
bool PgArchCanRestart | ( | void | ) |
void PgArchForceDirScan | ( | void | ) |
Definition at line 710 of file pgarch.c.
References PgArchData::arch_lck, PgArchData::force_dir_scan, PgArch, SpinLockAcquire, and SpinLockRelease.
Referenced by XLogArchiveNotify().
void PgArchiverMain | ( | void | ) |
Definition at line 212 of file pgarch.c.
References arch_files, arch_files_state::arch_files_size, arch_files_state::arch_heap, Assert(), binaryheap_allocate(), LoadArchiveLibrary(), MyProc, NUM_FILES_PER_DIRECTORY_SCAN, on_shmem_exit(), palloc(), PgArch, pgarch_die(), pgarch_MainLoop(), pgarch_waken_stop(), PgArchData::pgprocno, PGPROC::pgprocno, pqsignal(), proc_exit(), procsignal_sigusr1_handler(), ready_file_comparator(), SIG_DFL, SIG_IGN, SIGALRM, SIGCHLD, SIGHUP, SignalHandlerForConfigReload(), SignalHandlerForShutdownRequest(), SIGPIPE, SIGUSR1, SIGUSR2, UnBlockSig, and XLogArchivingActive.
Referenced by AuxiliaryProcessMain().
void PgArchShmemInit | ( | void | ) |
Definition at line 163 of file pgarch.c.
References PgArchData::arch_lck, INVALID_PGPROCNO, MemSet, PgArch, PgArchShmemSize(), PgArchData::pgprocno, ShmemInitStruct(), and SpinLockInit.
Referenced by CreateSharedMemoryAndSemaphores().
Size PgArchShmemSize | ( | void | ) |
Definition at line 152 of file pgarch.c.
References add_size().
Referenced by CalculateShmemSize(), and PgArchShmemInit().
void PgArchWakeup | ( | void | ) |
Definition at line 265 of file pgarch.c.
References PROC_HDR::allProcs, INVALID_PGPROCNO, PgArch, PgArchData::pgprocno, ProcGlobal, PGPROC::procLatch, and SetLatch().
Referenced by XLogArchiveNotify().
Definition at line 687 of file pgarch.c.
References a, b, DatumGetCString(), and IsTLHistoryFileName().
Referenced by pgarch_readyXlog(), and PgArchiverMain().
|
static |
Definition at line 127 of file pgarch.c.
Referenced by pgarch_ArchiverCopyLoop(), pgarch_readyXlog(), and PgArchiverMain().
|
static |
Definition at line 101 of file pgarch.c.
Referenced by LoadArchiveLibrary(), pgarch_ArchiverCopyLoop(), pgarch_archiveXlog(), and pgarch_call_module_shutdown_cb().
|
static |
Definition at line 100 of file pgarch.c.
Referenced by LoadArchiveLibrary(), pgarch_ArchiverCopyLoop(), pgarch_archiveXlog(), and pgarch_call_module_shutdown_cb().
|
static |
Definition at line 98 of file pgarch.c.
Referenced by pgarch_MainLoop().
|
static |
Definition at line 99 of file pgarch.c.
Referenced by pgarch_die(), pgarch_readyXlog(), PgArchForceDirScan(), PgArchiverMain(), PgArchShmemInit(), and PgArchWakeup().
|
static |
Definition at line 132 of file pgarch.c.
Referenced by pgarch_MainLoop(), and pgarch_waken_stop().
char* XLogArchiveLibrary = "" |
Definition at line 91 of file pgarch.c.
Referenced by HandlePgArchInterrupts(), and LoadArchiveLibrary().