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

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 196 of file pgarch.c.

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

References fb(), and PGARCH_RESTART_INTERVAL.

Referenced by LaunchMissingBackgroundProcesses().

◆ PgArchForceDirScan()

void PgArchForceDirScan ( void  )
extern

Definition at line 805 of file pgarch.c.

808{

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 219 of file pgarch.c.

222{
224
226
227 /*
228 * Ignore all signals usually bound to some action in the postmaster,
229 * except for SIGHUP, SIGTERM, SIGUSR1, SIGUSR2, and SIGQUIT.
230 */
234 /* SIGQUIT handler was already set up by InitPostmasterChild */
239
240 /* Reset some signals that are accepted by postmaster but not here */
242
243 /* Unblock signals (they were blocked when the postmaster forked us) */
245
246 /* We shouldn't be launched unnecessarily. */
248
249 /* Arrange to clean up at archiver exit */
251
252 /*
253 * Advertise our proc number so that backends can use our latch to wake us
254 * up while we're sleeping.
255 */
257
258 /* Create workspace for pgarch_readyXlog() */
261
262 /* Initialize our max-heap for prioritizing files to archive. */
265
266 /* Initialize our memory context. */
268 "archiver",
270
271 /* Load the archive_library. */
273
275
void AuxiliaryProcessMainCommon(void)
Definition auxprocess.c:41
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:943
#define palloc_object(type)
Definition fe_memutils.h:74
ProcNumber MyProcNumber
Definition globals.c:92
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:848
static PgArchData * PgArch
Definition pgarch.c:104
static void pgarch_MainLoop(void)
Definition pgarch.c:311
static void pgarch_waken_stop(SIGNAL_ARGS)
Definition pgarch.c:298
static struct arch_files_state * arch_files
Definition pgarch.c:133
static void LoadArchiveLibrary(void)
Definition pgarch.c:914
static int ready_file_comparator(Datum a, Datum b, void *arg)
Definition pgarch.c:782
#define NUM_FILES_PER_DIRECTORY_SCAN
Definition pgarch.c:82
static MemoryContext archive_context
Definition pgarch.c:107
#define pqsignal
Definition port.h:547
void procsignal_sigusr1_handler(SIGNAL_ARGS)
Definition procsignal.c:688
int pgprocno
Definition pgarch.c:87
int arch_files_size
Definition pgarch.c:127
binaryheap * arch_heap
Definition pgarch.c:126
#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:102

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.

◆ PgArchWakeup()

void PgArchWakeup ( void  )
extern

Definition at line 281 of file pgarch.c.

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

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

Referenced by XLogArchiveNotify().