PostgreSQL Source Code git master
Loading...
Searching...
No Matches
pgarch.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define MIN_XFN_CHARS   16
 
#define MAX_XFN_CHARS   40
 
#define VALID_XFN_CHARS   "0123456789ABCDEF.history.backup.partial"
 

Functions

Size PgArchShmemSize (void)
 
void PgArchShmemInit (void)
 
bool PgArchCanRestart (void)
 
pg_noreturn void PgArchiverMain (const void *startup_data, size_t startup_data_len)
 
void PgArchWakeup (void)
 
void PgArchForceDirScan (void)
 

Macro Definition Documentation

◆ MAX_XFN_CHARS

#define MAX_XFN_CHARS   40

Definition at line 26 of file pgarch.h.

◆ MIN_XFN_CHARS

#define MIN_XFN_CHARS   16

Definition at line 25 of file pgarch.h.

◆ VALID_XFN_CHARS

#define VALID_XFN_CHARS   "0123456789ABCDEF.history.backup.partial"

Definition at line 27 of file pgarch.h.

Function Documentation

◆ PgArchCanRestart()

bool PgArchCanRestart ( void  )
extern

Definition at line 197 of file pgarch.c.

200{
202 time_t curtime = time(NULL);
203
204 /*
205 * If first time through, or time somehow went backwards, always update
206 * last_pgarch_start_time to match the current clock and allow archiver
207 * start. Otherwise allow it only once enough time has elapsed.
208 */
209 if (last_pgarch_start_time == 0 ||
212 {
214 return true;
215 }
#define PGARCH_RESTART_INTERVAL
Definition pgarch.c:64
static int fb(int x)

References fb(), and PGARCH_RESTART_INTERVAL.

Referenced by LaunchMissingBackgroundProcesses().

◆ PgArchForceDirScan()

void PgArchForceDirScan ( void  )
extern

Definition at line 806 of file pgarch.c.

809{

References PgArchData::force_dir_scan, pg_atomic_write_membarrier_u32(), and PgArch.

Referenced by XLogArchiveNotify().

◆ PgArchiverMain()

pg_noreturn void PgArchiverMain ( const void startup_data,
size_t  startup_data_len 
)
extern

Definition at line 220 of file pgarch.c.

223{
225
227
228 /*
229 * Ignore all signals usually bound to some action in the postmaster,
230 * except for SIGHUP, SIGTERM, SIGUSR1, SIGUSR2, and SIGQUIT.
231 */
235 /* SIGQUIT handler was already set up by InitPostmasterChild */
240
241 /* Reset some signals that are accepted by postmaster but not here */
243
244 /* Unblock signals (they were blocked when the postmaster forked us) */
246
247 /* We shouldn't be launched unnecessarily. */
249
250 /* Arrange to clean up at archiver exit */
252
253 /*
254 * Advertise our proc number so that backends can use our latch to wake us
255 * up while we're sleeping.
256 */
258
259 /* Create workspace for pgarch_readyXlog() */
262
263 /* Initialize our max-heap for prioritizing files to archive. */
266
267 /* Initialize our memory context. */
269 "archiver",
271
272 /* Load the archive_library. */
274
276
void AuxiliaryProcessMainCommon(void)
Definition auxprocess.c:40
sigset_t UnBlockSig
Definition pqsignal.c:22
binaryheap * binaryheap_allocate(int capacity, binaryheap_comparator compare, void *arg)
Definition binaryheap.c:37
#define Assert(condition)
Definition c.h:945
#define palloc_object(type)
Definition fe_memutils.h:74
ProcNumber MyProcNumber
Definition globals.c:90
void SignalHandlerForShutdownRequest(SIGNAL_ARGS)
Definition interrupt.c:104
void SignalHandlerForConfigReload(SIGNAL_ARGS)
Definition interrupt.c:61
void on_shmem_exit(pg_on_exit_callback function, Datum arg)
Definition ipc.c:372
MemoryContext TopMemoryContext
Definition mcxt.c:166
#define AllocSetContextCreate
Definition memutils.h:129
#define ALLOCSET_DEFAULT_SIZES
Definition memutils.h:160
static void pgarch_die(int code, Datum arg)
Definition pgarch.c:849
static PgArchData * PgArch
Definition pgarch.c:103
static void pgarch_MainLoop(void)
Definition pgarch.c:312
static void pgarch_waken_stop(SIGNAL_ARGS)
Definition pgarch.c:299
static struct arch_files_state * arch_files
Definition pgarch.c:132
static void LoadArchiveLibrary(void)
Definition pgarch.c:915
static int ready_file_comparator(Datum a, Datum b, void *arg)
Definition pgarch.c:783
#define NUM_FILES_PER_DIRECTORY_SCAN
Definition pgarch.c:81
static MemoryContext archive_context
Definition pgarch.c:106
#define pqsignal
Definition port.h:547
void procsignal_sigusr1_handler(SIGNAL_ARGS)
Definition procsignal.c:680
int pgprocno
Definition pgarch.c:86
int arch_files_size
Definition pgarch.c:126
binaryheap * arch_heap
Definition pgarch.c:125
#define SIGCHLD
Definition win32_port.h:168
#define SIGHUP
Definition win32_port.h:158
#define SIGPIPE
Definition win32_port.h:163
#define SIGUSR1
Definition win32_port.h:170
#define SIGALRM
Definition win32_port.h:164
#define SIGUSR2
Definition win32_port.h:171
#define XLogArchivingActive()
Definition xlog.h:101

References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, arch_files, arch_files_state::arch_files_size, arch_files_state::arch_heap, archive_context, Assert, AuxiliaryProcessMainCommon(), binaryheap_allocate(), fb(), LoadArchiveLibrary(), MyProcNumber, NUM_FILES_PER_DIRECTORY_SCAN, on_shmem_exit(), palloc_object, PgArch, pgarch_die(), pgarch_MainLoop(), pgarch_waken_stop(), PgArchData::pgprocno, pqsignal, proc_exit(), procsignal_sigusr1_handler(), ready_file_comparator(), SIGALRM, SIGCHLD, SIGHUP, SignalHandlerForConfigReload(), SignalHandlerForShutdownRequest(), SIGPIPE, SIGUSR1, SIGUSR2, TopMemoryContext, UnBlockSig, and XLogArchivingActive.

◆ PgArchShmemInit()

void PgArchShmemInit ( void  )
extern

Definition at line 168 of file pgarch.c.

171{
172 bool found;
173
174 PgArch = (PgArchData *)
175 ShmemInitStruct("Archiver Data", PgArchShmemSize(), &found);
176
177 if (!found)
178 {
179 /* First time through, so initialize */
static void pg_atomic_init_u32(volatile pg_atomic_uint32 *ptr, uint32 val)
Definition atomics.h:219
#define MemSet(start, val, len)
Definition c.h:1109
Size PgArchShmemSize(void)
Definition pgarch.c:157
#define INVALID_PROC_NUMBER
Definition procnumber.h:26
void * ShmemInitStruct(const char *name, Size size, bool *foundPtr)
Definition shmem.c:381
pg_atomic_uint32 force_dir_scan
Definition pgarch.c:91

References PgArchData::force_dir_scan, INVALID_PROC_NUMBER, MemSet, pg_atomic_init_u32(), PgArch, PgArchShmemSize(), PgArchData::pgprocno, and ShmemInitStruct().

Referenced by CreateOrAttachShmemStructs().

◆ PgArchShmemSize()

Size PgArchShmemSize ( void  )
extern

Definition at line 157 of file pgarch.c.

160{
161 Size size = 0;
162
163 size = add_size(size, sizeof(PgArchData));
164
size_t Size
Definition c.h:691
Size add_size(Size s1, Size s2)
Definition shmem.c:485

References add_size().

Referenced by CalculateShmemSize(), and PgArchShmemInit().

◆ PgArchWakeup()

void PgArchWakeup ( void  )
extern

Definition at line 282 of file pgarch.c.

285{
287
288 /*
289 * We don't acquire ProcArrayLock here. It's actually fine because
290 * procLatch isn't ever freed, so we just can potentially set the wrong
291 * process' (or no process') latch. Even in that case the archiver will
292 * be relaunched shortly and will start archiving.
293 */

References fb(), GetPGProcByNumber, INVALID_PROC_NUMBER, PgArch, PgArchData::pgprocno, and SetLatch().

Referenced by XLogArchiveNotify().