PostgreSQL Source Code git master
Loading...
Searching...
No Matches
bgwriter.h File Reference
#include "parser/parse_node.h"
#include "storage/block.h"
#include "storage/relfilelocator.h"
#include "storage/smgr.h"
#include "storage/sync.h"
Include dependency graph for bgwriter.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

pg_noreturn void BackgroundWriterMain (const void *startup_data, size_t startup_data_len)
 
pg_noreturn void CheckpointerMain (const void *startup_data, size_t startup_data_len)
 
void ExecCheckpoint (ParseState *pstate, CheckPointStmt *stmt)
 
void RequestCheckpoint (int flags)
 
void CheckpointWriteDelay (int flags, double progress)
 
bool ForwardSyncRequest (const FileTag *ftag, SyncRequestType type)
 
void AbsorbSyncRequests (void)
 
Size CheckpointerShmemSize (void)
 
void CheckpointerShmemInit (void)
 
bool FirstCallSinceLastCheckpoint (void)
 

Variables

PGDLLIMPORT int BgWriterDelay
 
PGDLLIMPORT int CheckPointTimeout
 
PGDLLIMPORT int CheckPointWarning
 
PGDLLIMPORT double CheckPointCompletionTarget
 

Function Documentation

◆ AbsorbSyncRequests()

void AbsorbSyncRequests ( void  )
extern

Definition at line 1436 of file checkpointer.c.

1437{
1438 CheckpointerRequest *requests = NULL;
1440 int n,
1441 i;
1442 bool loop;
1443
1444 if (!AmCheckpointerProcess())
1445 return;
1446
1447 do
1448 {
1450
1451 /*---
1452 * We try to avoid holding the lock for a long time by:
1453 * 1. Copying the request array and processing the requests after
1454 * releasing the lock;
1455 * 2. Processing not the whole queue, but only batches of
1456 * CKPT_REQ_BATCH_SIZE at once.
1457 *
1458 * Once we have cleared the requests from shared memory, we must
1459 * PANIC if we then fail to absorb them (e.g., because our hashtable
1460 * runs out of memory). This is because the system cannot run safely
1461 * if we are unable to fsync what we have been told to fsync.
1462 * Fortunately, the hashtable is so small that the problem is quite
1463 * unlikely to arise in practice.
1464 *
1465 * Note: The maximum possible size of a ring buffer is
1466 * MAX_CHECKPOINT_REQUESTS entries, which fit into a maximum palloc
1467 * allocation size of 1Gb. Our maximum batch size,
1468 * CKPT_REQ_BATCH_SIZE, is even smaller.
1469 */
1471 if (n > 0)
1472 {
1473 if (!requests)
1474 requests = (CheckpointerRequest *) palloc(n * sizeof(CheckpointerRequest));
1475
1476 for (i = 0; i < n; i++)
1477 {
1480 }
1481
1483
1484 }
1485
1487
1488 /* Are there any requests in the queue? If so, keep going. */
1490
1492
1493 for (request = requests; n > 0; request++, n--)
1494 RememberSyncRequest(&request->ftag, request->type);
1495
1497 } while (loop);
1498
1499 if (requests)
1500 pfree(requests);
1501}
#define Min(x, y)
Definition c.h:997
#define CKPT_REQ_BATCH_SIZE
static CheckpointerShmemStruct * CheckpointerShmem
int i
Definition isn.c:77
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
Definition lwlock.c:1176
void LWLockRelease(LWLock *lock)
Definition lwlock.c:1793
@ LW_EXCLUSIVE
Definition lwlock.h:112
void pfree(void *pointer)
Definition mcxt.c:1616
void * palloc(Size size)
Definition mcxt.c:1387
#define AmCheckpointerProcess()
Definition miscadmin.h:389
#define START_CRIT_SECTION()
Definition miscadmin.h:150
#define END_CRIT_SECTION()
Definition miscadmin.h:152
static int fb(int x)
CheckpointerRequest requests[FLEXIBLE_ARRAY_MEMBER]
void RememberSyncRequest(const FileTag *ftag, SyncRequestType type)
Definition sync.c:487

References AmCheckpointerProcess, CheckpointerShmem, CKPT_REQ_BATCH_SIZE, END_CRIT_SECTION, fb(), CheckpointerShmemStruct::head, i, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), CheckpointerShmemStruct::max_requests, Min, CheckpointerShmemStruct::num_requests, palloc(), pfree(), RememberSyncRequest(), CheckpointerShmemStruct::requests, and START_CRIT_SECTION.

Referenced by CheckpointerMain(), CheckpointWriteDelay(), CreateCheckPoint(), ProcessSyncRequests(), SyncPostCheckpoint(), and SyncPreCheckpoint().

◆ BackgroundWriterMain()

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

Definition at line 88 of file bgwriter.c.

89{
92 bool prev_hibernate;
94
96
98
99 /*
100 * Properly accept or ignore signals that might be sent to us.
101 */
105 /* SIGQUIT handler was already set up by InitPostmasterChild */
110
111 /*
112 * Reset some signals that are accepted by postmaster but not here
113 */
115
116 /*
117 * We just started, assume there has been either a shutdown or
118 * end-of-recovery snapshot.
119 */
121
122 /*
123 * Create a memory context that we will do all our work in. We do this so
124 * that we can reset the context during error recovery and thereby avoid
125 * possible memory leaks. Formerly this code just ran in
126 * TopMemoryContext, but resetting that would be a really bad idea.
127 */
129 "Background Writer",
132
134
135 /*
136 * If an exception is encountered, processing resumes here.
137 *
138 * You might wonder why this isn't coded as an infinite loop around a
139 * PG_TRY construct. The reason is that this is the bottom of the
140 * exception stack, and so with PG_TRY there would be no exception handler
141 * in force at all during the CATCH part. By leaving the outermost setjmp
142 * always active, we have at least some chance of recovering from an error
143 * during error recovery. (If we get into an infinite loop thereby, it
144 * will soon be stopped by overflow of elog.c's internal state stack.)
145 *
146 * Note that we use sigsetjmp(..., 1), so that the prevailing signal mask
147 * (to wit, BlockSig) will be restored when longjmp'ing to here. Thus,
148 * signals other than SIGQUIT will be blocked until we complete error
149 * recovery. It might seem that this policy makes the HOLD_INTERRUPTS()
150 * call redundant, but it is not since InterruptPending might be set
151 * already.
152 */
153 if (sigsetjmp(local_sigjmp_buf, 1) != 0)
154 {
155 /* Since not using PG_TRY, must reset error stack by hand */
157
158 /* Prevent interrupts while cleaning up */
160
161 /* Report the error to the server log */
163
164 /*
165 * These operations are really just a minimal subset of
166 * AbortTransaction(). We don't have very many resources to worry
167 * about in bgwriter, but we do have LWLocks, buffers, and temp files.
168 */
174 AtEOXact_Buffers(false);
176 AtEOXact_Files(false);
177 AtEOXact_HashTables(false);
178
179 /*
180 * Now return to normal top-level context and clear ErrorContext for
181 * next time.
182 */
185
186 /* Flush any leaked data in the top-level context */
188
189 /* re-initialize to avoid repeated errors causing problems */
191
192 /* Now we can allow interrupts again */
194
195 /*
196 * Sleep at least 1 second after any error. A write error is likely
197 * to be repeated, and we don't want to be filling the error logs as
198 * fast as we can.
199 */
200 pg_usleep(1000000L);
201
202 /* Report wait end here, when there is no further possibility of wait */
204 }
205
206 /* We can now handle ereport(ERROR) */
208
209 /*
210 * Unblock signals (they were blocked when the postmaster forked us)
211 */
213
214 /*
215 * Reset hibernation state after any error.
216 */
217 prev_hibernate = false;
218
219 /*
220 * Loop forever
221 */
222 for (;;)
223 {
224 bool can_hibernate;
225 int rc;
226
227 /* Clear any already-pending wakeups */
229
231
232 /*
233 * Do one cycle of dirty-buffer writing.
234 */
236
237 /* Report pending statistics to the cumulative stats system */
239 pgstat_report_wal(true);
240
242 {
243 /*
244 * After any checkpoint, free all smgr objects. Otherwise we
245 * would never do so for dropped relations, as the bgwriter does
246 * not process shared invalidation messages or call
247 * AtEOXact_SMgr().
248 */
250 }
251
252 /*
253 * Log a new xl_running_xacts every now and then so replication can
254 * get into a consistent state faster (think of suboverflowed
255 * snapshots) and clean up resources (locks, KnownXids*) more
256 * frequently. The costs of this are relatively low, so doing it 4
257 * times (LOG_SNAPSHOT_INTERVAL_MS) a minute seems fine.
258 *
259 * We assume the interval for writing xl_running_xacts is
260 * significantly bigger than BgWriterDelay, so we don't complicate the
261 * overall timeout handling but just assume we're going to get called
262 * often enough even if hibernation mode is active. It's not that
263 * important that LOG_SNAPSHOT_INTERVAL_MS is met strictly. To make
264 * sure we're not waking the disk up unnecessarily on an idle system
265 * we check whether there has been any WAL inserted since the last
266 * time we've logged a running xacts.
267 *
268 * We do this logging in the bgwriter as it is the only process that
269 * is run regularly and returns to its mainloop all the time. E.g.
270 * Checkpointer, when active, is barely ever in its mainloop and thus
271 * makes it hard to log regularly.
272 */
274 {
277
280
281 /*
282 * Only log if enough time has passed and interesting records have
283 * been inserted since the last snapshot. Have to compare with <=
284 * instead of < because GetLastImportantRecPtr() points at the
285 * start of a record, whereas last_snapshot_lsn points just past
286 * the end of the record.
287 */
288 if (now >= timeout &&
290 {
293 }
294 }
295
296 /*
297 * Sleep until we are signaled or BgWriterDelay has elapsed.
298 *
299 * Note: the feedback control loop in BgBufferSync() expects that we
300 * will call it every BgWriterDelay msec. While it's not critical for
301 * correctness that that be exact, the feedback loop might misbehave
302 * if we stray too far from that. Hence, avoid loading this process
303 * down with latch events that are likely to happen frequently during
304 * normal operation.
305 */
306 rc = WaitLatch(MyLatch,
309
310 /*
311 * If no latch event and BgBufferSync says nothing's happening, extend
312 * the sleep in "hibernation" mode, where we sleep for much longer
313 * than bgwriter_delay says. Fewer wakeups save electricity. When a
314 * backend starts using buffers again, it will wake us up by setting
315 * our latch. Because the extra sleep will persist only as long as no
316 * buffer allocations happen, this should not distort the behavior of
317 * BgBufferSync's control loop too badly; essentially, it will think
318 * that the system-wide idle interval didn't exist.
319 *
320 * There is a race condition here, in that a backend might allocate a
321 * buffer between the time BgBufferSync saw the alloc count as zero
322 * and the time we call StrategyNotifyBgWriter. While it's not
323 * critical that we not hibernate anyway, we try to reduce the odds of
324 * that by only hibernating when BgBufferSync says nothing's happening
325 * for two consecutive cycles. Also, we mitigate any possible
326 * consequences of a missed wakeup by not hibernating forever.
327 */
329 {
330 /* Ask for notification at next buffer allocation */
332 /* Sleep ... */
337 /* Reset the notification request in case we timed out */
339 }
340
342 }
343}
void pgaio_error_cleanup(void)
Definition aio.c:1165
void AuxiliaryProcessMainCommon(void)
Definition auxprocess.c:39
sigset_t UnBlockSig
Definition pqsignal.c:22
TimestampTz GetCurrentTimestamp(void)
Definition timestamp.c:1645
Datum now(PG_FUNCTION_ARGS)
Definition timestamp.c:1609
static XLogRecPtr last_snapshot_lsn
Definition bgwriter.c:78
static TimestampTz last_snapshot_ts
Definition bgwriter.c:77
int BgWriterDelay
Definition bgwriter.c:58
#define HIBERNATE_FACTOR
Definition bgwriter.c:64
#define LOG_SNAPSHOT_INTERVAL_MS
Definition bgwriter.c:70
void AtEOXact_Buffers(bool isCommit)
Definition bufmgr.c:4103
bool BgBufferSync(WritebackContext *wb_context)
Definition bufmgr.c:3735
void UnlockBuffers(void)
Definition bufmgr.c:5709
int bgwriter_flush_after
Definition bufmgr.c:208
void WritebackContextInit(WritebackContext *context, int *max_pending)
Definition bufmgr.c:7267
#define Assert(condition)
Definition c.h:873
bool FirstCallSinceLastCheckpoint(void)
bool ConditionVariableCancelSleep(void)
int64 TimestampTz
Definition timestamp.h:39
void AtEOXact_HashTables(bool isCommit)
Definition dynahash.c:1931
void EmitErrorReport(void)
Definition elog.c:1704
ErrorContextCallback * error_context_stack
Definition elog.c:95
void FlushErrorState(void)
Definition elog.c:1884
sigjmp_buf * PG_exception_stack
Definition elog.c:97
void AtEOXact_Files(bool isCommit)
Definition fd.c:3213
void StrategyNotifyBgWriter(int bgwprocno)
Definition freelist.c:358
ProcNumber MyProcNumber
Definition globals.c:90
struct Latch * MyLatch
Definition globals.c:63
void SignalHandlerForShutdownRequest(SIGNAL_ARGS)
Definition interrupt.c:104
void ProcessMainLoopInterrupts(void)
Definition interrupt.c:34
void SignalHandlerForConfigReload(SIGNAL_ARGS)
Definition interrupt.c:61
void ResetLatch(Latch *latch)
Definition latch.c:374
int WaitLatch(Latch *latch, int wakeEvents, long timeout, uint32 wait_event_info)
Definition latch.c:172
void LWLockReleaseAll(void)
Definition lwlock.c:1892
void MemoryContextReset(MemoryContext context)
Definition mcxt.c:403
MemoryContext TopMemoryContext
Definition mcxt.c:166
#define AllocSetContextCreate
Definition memutils.h:129
#define ALLOCSET_DEFAULT_SIZES
Definition memutils.h:160
#define RESUME_INTERRUPTS()
Definition miscadmin.h:136
#define HOLD_INTERRUPTS()
Definition miscadmin.h:134
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition palloc.h:124
void pgstat_report_bgwriter(void)
void pgstat_report_wal(bool force)
Definition pgstat_wal.c:46
#define pqsignal
Definition port.h:547
void procsignal_sigusr1_handler(SIGNAL_ARGS)
Definition procsignal.c:677
void ReleaseAuxProcessResources(bool isCommit)
Definition resowner.c:1016
void pg_usleep(long microsec)
Definition signal.c:53
void smgrdestroyall(void)
Definition smgr.c:386
void AtEOXact_SMgr(void)
Definition smgr.c:1017
XLogRecPtr LogStandbySnapshot(void)
Definition standby.c:1281
#define TimestampTzPlusMilliseconds(tz, ms)
Definition timestamp.h:85
static void pgstat_report_wait_end(void)
Definition wait_event.h:85
#define WL_TIMEOUT
#define WL_EXIT_ON_PM_DEATH
#define WL_LATCH_SET
#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
bool RecoveryInProgress(void)
Definition xlog.c:6460
XLogRecPtr GetLastImportantRecPtr(void)
Definition xlog.c:6682
#define XLogStandbyInfoActive()
Definition xlog.h:125

References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, Assert, AtEOXact_Buffers(), AtEOXact_Files(), AtEOXact_HashTables(), AtEOXact_SMgr(), AuxiliaryProcessMainCommon(), BgBufferSync(), bgwriter_flush_after, BgWriterDelay, ConditionVariableCancelSleep(), EmitErrorReport(), error_context_stack, fb(), FirstCallSinceLastCheckpoint(), FlushErrorState(), GetCurrentTimestamp(), GetLastImportantRecPtr(), HIBERNATE_FACTOR, HOLD_INTERRUPTS, last_snapshot_lsn, last_snapshot_ts, LOG_SNAPSHOT_INTERVAL_MS, LogStandbySnapshot(), LWLockReleaseAll(), MemoryContextReset(), MemoryContextSwitchTo(), MyLatch, MyProcNumber, now(), PG_exception_stack, pg_usleep(), pgaio_error_cleanup(), pgstat_report_bgwriter(), pgstat_report_wait_end(), pgstat_report_wal(), pqsignal, ProcessMainLoopInterrupts(), procsignal_sigusr1_handler(), RecoveryInProgress(), ReleaseAuxProcessResources(), ResetLatch(), RESUME_INTERRUPTS, SIGALRM, SIGCHLD, SIGHUP, SignalHandlerForConfigReload(), SignalHandlerForShutdownRequest(), SIGPIPE, SIGUSR1, SIGUSR2, smgrdestroyall(), StrategyNotifyBgWriter(), TimestampTzPlusMilliseconds, TopMemoryContext, UnBlockSig, UnlockBuffers(), WaitLatch(), WL_EXIT_ON_PM_DEATH, WL_LATCH_SET, WL_TIMEOUT, WritebackContextInit(), and XLogStandbyInfoActive.

◆ CheckpointerMain()

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

Definition at line 195 of file checkpointer.c.

196{
199
201
203
205
206 /*
207 * Properly accept or ignore signals the postmaster might send us
208 *
209 * Note: we deliberately ignore SIGTERM, because during a standard Unix
210 * system shutdown cycle, init will SIGTERM all processes at once. We
211 * want to wait for the backends to exit, whereupon the postmaster will
212 * tell us it's okay to shut down (via SIGUSR2).
213 */
216 pqsignal(SIGTERM, SIG_IGN); /* ignore SIGTERM */
217 /* SIGQUIT handler was already set up by InitPostmasterChild */
222
223 /*
224 * Reset some signals that are accepted by postmaster but not here
225 */
227
228 /*
229 * Initialize so that first time-driven event happens at the correct time.
230 */
232
233 /*
234 * Write out stats after shutdown. This needs to be called by exactly one
235 * process during a normal shutdown, and since checkpointer is shut down
236 * very late...
237 *
238 * While e.g. walsenders are active after the shutdown checkpoint has been
239 * written (and thus could produce more stats), checkpointer stays around
240 * after the shutdown checkpoint has been written. postmaster will only
241 * signal checkpointer to exit after all processes that could emit stats
242 * have been shut down.
243 */
245
246 /*
247 * Create a memory context that we will do all our work in. We do this so
248 * that we can reset the context during error recovery and thereby avoid
249 * possible memory leaks. Formerly this code just ran in
250 * TopMemoryContext, but resetting that would be a really bad idea.
251 */
253 "Checkpointer",
256
257 /*
258 * If an exception is encountered, processing resumes here.
259 *
260 * You might wonder why this isn't coded as an infinite loop around a
261 * PG_TRY construct. The reason is that this is the bottom of the
262 * exception stack, and so with PG_TRY there would be no exception handler
263 * in force at all during the CATCH part. By leaving the outermost setjmp
264 * always active, we have at least some chance of recovering from an error
265 * during error recovery. (If we get into an infinite loop thereby, it
266 * will soon be stopped by overflow of elog.c's internal state stack.)
267 *
268 * Note that we use sigsetjmp(..., 1), so that the prevailing signal mask
269 * (to wit, BlockSig) will be restored when longjmp'ing to here. Thus,
270 * signals other than SIGQUIT will be blocked until we complete error
271 * recovery. It might seem that this policy makes the HOLD_INTERRUPTS()
272 * call redundant, but it is not since InterruptPending might be set
273 * already.
274 */
275 if (sigsetjmp(local_sigjmp_buf, 1) != 0)
276 {
277 /* Since not using PG_TRY, must reset error stack by hand */
279
280 /* Prevent interrupts while cleaning up */
282
283 /* Report the error to the server log */
285
286 /*
287 * These operations are really just a minimal subset of
288 * AbortTransaction(). We don't have very many resources to worry
289 * about in checkpointer, but we do have LWLocks, buffers, and temp
290 * files.
291 */
298 AtEOXact_Buffers(false);
300 AtEOXact_Files(false);
301 AtEOXact_HashTables(false);
302
303 /* Warn any waiting backends that the checkpoint failed. */
304 if (ckpt_active)
305 {
310
312
313 ckpt_active = false;
314 }
315
316 /*
317 * Now return to normal top-level context and clear ErrorContext for
318 * next time.
319 */
322
323 /* Flush any leaked data in the top-level context */
325
326 /* Now we can allow interrupts again */
328
329 /*
330 * Sleep at least 1 second after any error. A write error is likely
331 * to be repeated, and we don't want to be filling the error logs as
332 * fast as we can.
333 */
334 pg_usleep(1000000L);
335 }
336
337 /* We can now handle ereport(ERROR) */
339
340 /*
341 * Unblock signals (they were blocked when the postmaster forked us)
342 */
344
345 /*
346 * Ensure all shared memory values are set correctly for the config. Doing
347 * this here ensures no race conditions from other concurrent updaters.
348 */
350
351 /*
352 * Advertise our proc number that backends can use to wake us up while
353 * we're sleeping.
354 */
356
357 /*
358 * Loop until we've been asked to write the shutdown checkpoint or
359 * terminate.
360 */
361 for (;;)
362 {
363 bool do_checkpoint = false;
364 int flags = 0;
366 int elapsed_secs;
367 int cur_timeout;
368 bool chkpt_or_rstpt_requested = false;
369 bool chkpt_or_rstpt_timed = false;
370
371 /* Clear any already-pending wakeups */
373
374 /*
375 * Process any requests or signals received recently.
376 */
378
381 break;
382
383 /*
384 * Detect a pending checkpoint request by checking whether the flags
385 * word in shared memory is nonzero. We shouldn't need to acquire the
386 * ckpt_lck for this.
387 */
388 if (((volatile CheckpointerShmemStruct *) CheckpointerShmem)->ckpt_flags)
389 {
390 do_checkpoint = true;
392 }
393
394 /*
395 * Force a checkpoint if too much time has elapsed since the last one.
396 * Note that we count a timed checkpoint in stats only when this
397 * occurs without an external request, but we set the CAUSE_TIME flag
398 * bit even if there is also an external request.
399 */
400 now = (pg_time_t) time(NULL);
403 {
404 if (!do_checkpoint)
406 do_checkpoint = true;
407 flags |= CHECKPOINT_CAUSE_TIME;
408 }
409
410 /*
411 * Do a checkpoint if requested.
412 */
413 if (do_checkpoint)
414 {
415 bool ckpt_performed = false;
416 bool do_restartpoint;
417
418 /* Check if we should perform a checkpoint or a restartpoint. */
420
421 /*
422 * Atomically fetch the request flags to figure out what kind of a
423 * checkpoint we should perform, and increase the started-counter
424 * to acknowledge that we've started a new checkpoint.
425 */
431
433
434 /*
435 * The end-of-recovery checkpoint is a real checkpoint that's
436 * performed while we're still in recovery.
437 */
438 if (flags & CHECKPOINT_END_OF_RECOVERY)
439 do_restartpoint = false;
440
442 {
443 chkpt_or_rstpt_timed = false;
444 if (do_restartpoint)
446 else
448 }
449
451 {
453 if (do_restartpoint)
455 else
457 }
458
459 /*
460 * We will warn if (a) too soon since last checkpoint (whatever
461 * caused it) and (b) somebody set the CHECKPOINT_CAUSE_XLOG flag
462 * since the last checkpoint start. Note in particular that this
463 * implementation will not generate warnings caused by
464 * CheckPointTimeout < CheckPointWarning.
465 */
466 if (!do_restartpoint &&
467 (flags & CHECKPOINT_CAUSE_XLOG) &&
469 ereport(LOG,
470 (errmsg_plural("checkpoints are occurring too frequently (%d second apart)",
471 "checkpoints are occurring too frequently (%d seconds apart)",
474 errhint("Consider increasing the configuration parameter \"%s\".", "max_wal_size")));
475
476 /*
477 * Initialize checkpointer-private variables used during
478 * checkpoint.
479 */
480 ckpt_active = true;
481 if (do_restartpoint)
483 else
487
488 /*
489 * Do the checkpoint.
490 */
491 if (!do_restartpoint)
493 else
495
496 /*
497 * After any checkpoint, free all smgr objects. Otherwise we
498 * would never do so for dropped relations, as the checkpointer
499 * does not process shared invalidation messages or call
500 * AtEOXact_SMgr().
501 */
503
504 /*
505 * Indicate checkpoint completion to any waiting backends.
506 */
510
512
513 if (!do_restartpoint)
514 {
515 /*
516 * Note we record the checkpoint start time not end time as
517 * last_checkpoint_time. This is so that time-driven
518 * checkpoints happen at a predictable spacing.
519 */
521
522 if (ckpt_performed)
524 }
525 else
526 {
527 if (ckpt_performed)
528 {
529 /*
530 * The same as for checkpoint. Please see the
531 * corresponding comment.
532 */
534
536 }
537 else
538 {
539 /*
540 * We were not able to perform the restartpoint
541 * (checkpoints throw an ERROR in case of error). Most
542 * likely because we have not received any new checkpoint
543 * WAL records since the last restartpoint. Try again in
544 * 15 s.
545 */
547 }
548 }
549
550 ckpt_active = false;
551
552 /*
553 * We may have received an interrupt during the checkpoint and the
554 * latch might have been reset (e.g. in CheckpointWriteDelay).
555 */
558 break;
559 }
560
561 /*
562 * Disable logical decoding if someone requested it. See comments atop
563 * logicalctl.c.
564 */
566
567 /* Check for archive_timeout and switch xlog files if necessary. */
569
570 /* Report pending statistics to the cumulative stats system */
572 pgstat_report_wal(true);
573
574 /*
575 * If any checkpoint flags have been set, redo the loop to handle the
576 * checkpoint without sleeping.
577 */
578 if (((volatile CheckpointerShmemStruct *) CheckpointerShmem)->ckpt_flags)
579 continue;
580
581 /*
582 * Sleep until we are signaled or it's time for another checkpoint or
583 * xlog file switch.
584 */
585 now = (pg_time_t) time(NULL);
588 continue; /* no sleep for us ... */
591 {
594 continue; /* no sleep for us ... */
596 }
597
600 cur_timeout * 1000L /* convert to ms */ ,
602 }
603
604 /*
605 * From here on, elog(ERROR) should end with exit(1), not send control
606 * back to the sigsetjmp block above.
607 */
608 ExitOnAnyError = true;
609
611 {
612 /*
613 * Close down the database.
614 *
615 * Since ShutdownXLOG() creates restartpoint or checkpoint, and
616 * updates the statistics, increment the checkpoint request and flush
617 * out pending statistic.
618 */
620 ShutdownXLOG(0, 0);
622 pgstat_report_wal(true);
623
624 /*
625 * Tell postmaster that we're done.
626 */
628 ShutdownXLOGPending = false;
629 }
630
631 /*
632 * Wait until we're asked to shut down. By separating the writing of the
633 * shutdown checkpoint from checkpointer exiting, checkpointer can perform
634 * some should-be-as-late-as-possible work like writing out stats.
635 */
636 for (;;)
637 {
638 /* Clear any already-pending wakeups */
640
642
644 break;
645
648 0,
650 }
651
652 /* Normal exit from the checkpointer is here */
653 proc_exit(0); /* done */
654}
static void UpdateSharedMemoryConfig(void)
static XLogRecPtr ckpt_start_recptr
static void ReqShutdownXLOG(SIGNAL_ARGS)
static void CheckArchiveTimeout(void)
static double ckpt_cached_elapsed
static bool ckpt_active
static void ProcessCheckpointerInterrupts(void)
static volatile sig_atomic_t ShutdownXLOGPending
void AbsorbSyncRequests(void)
static pg_time_t last_xlog_switch_time
int CheckPointWarning
int CheckPointTimeout
static pg_time_t last_checkpoint_time
static pg_time_t ckpt_start_time
void ConditionVariableBroadcast(ConditionVariable *cv)
int errmsg_plural(const char *fmt_singular, const char *fmt_plural, unsigned long n,...)
Definition elog.c:1193
int errhint(const char *fmt,...)
Definition elog.c:1330
#define LOG
Definition elog.h:31
#define ereport(elevel,...)
Definition elog.h:150
int MyProcPid
Definition globals.c:47
bool ExitOnAnyError
Definition globals.c:123
volatile sig_atomic_t ShutdownRequestPending
Definition interrupt.c:28
void before_shmem_exit(pg_on_exit_callback function, Datum arg)
Definition ipc.c:344
void proc_exit(int code)
Definition ipc.c:105
void DisableLogicalDecodingIfNecessary(void)
Definition logicalctl.c:460
void pgstat_before_server_shutdown(int code, Datum arg)
Definition pgstat.c:572
void pgstat_report_checkpointer(void)
PgStat_CheckpointerStats PendingCheckpointerStats
int64 pg_time_t
Definition pgtime.h:23
void SendPostmasterSignal(PMSignalReason reason)
Definition pmsignal.c:165
@ PMSIGNAL_XLOG_IS_SHUTDOWN
Definition pmsignal.h:44
#define SpinLockRelease(lock)
Definition spin.h:61
#define SpinLockAcquire(lock)
Definition spin.h:59
PROC_HDR * ProcGlobal
Definition proc.c:79
ConditionVariable done_cv
ConditionVariable start_cv
ProcNumber checkpointerProc
Definition proc.h:425
PgStat_Counter restartpoints_requested
Definition pgstat.h:262
PgStat_Counter num_requested
Definition pgstat.h:259
PgStat_Counter num_performed
Definition pgstat.h:260
PgStat_Counter restartpoints_timed
Definition pgstat.h:261
PgStat_Counter num_timed
Definition pgstat.h:258
PgStat_Counter restartpoints_performed
Definition pgstat.h:263
bool CreateRestartPoint(int flags)
Definition xlog.c:7721
XLogRecPtr GetInsertRecPtr(void)
Definition xlog.c:6608
void ShutdownXLOG(int code, Datum arg)
Definition xlog.c:6728
int XLogArchiveTimeout
Definition xlog.c:121
bool CreateCheckPoint(int flags)
Definition xlog.c:7015
#define CHECKPOINT_CAUSE_XLOG
Definition xlog.h:159
#define CHECKPOINT_END_OF_RECOVERY
Definition xlog.h:151
#define CHECKPOINT_CAUSE_TIME
Definition xlog.h:160
XLogRecPtr GetXLogReplayRecPtr(TimeLineID *replayTLI)

References AbsorbSyncRequests(), ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, Assert, AtEOXact_Buffers(), AtEOXact_Files(), AtEOXact_HashTables(), AtEOXact_SMgr(), AuxiliaryProcessMainCommon(), before_shmem_exit(), CheckArchiveTimeout(), CHECKPOINT_CAUSE_TIME, CHECKPOINT_CAUSE_XLOG, CHECKPOINT_END_OF_RECOVERY, CheckpointerShmemStruct::checkpointer_pid, PROC_HDR::checkpointerProc, CheckpointerShmem, CheckPointTimeout, CheckPointWarning, ckpt_active, ckpt_cached_elapsed, CheckpointerShmemStruct::ckpt_done, CheckpointerShmemStruct::ckpt_failed, CheckpointerShmemStruct::ckpt_flags, CheckpointerShmemStruct::ckpt_lck, ckpt_start_recptr, ckpt_start_time, CheckpointerShmemStruct::ckpt_started, ConditionVariableBroadcast(), ConditionVariableCancelSleep(), CreateCheckPoint(), CreateRestartPoint(), DisableLogicalDecodingIfNecessary(), CheckpointerShmemStruct::done_cv, EmitErrorReport(), ereport, errhint(), errmsg_plural(), error_context_stack, ExitOnAnyError, fb(), FlushErrorState(), GetInsertRecPtr(), GetXLogReplayRecPtr(), HOLD_INTERRUPTS, last_checkpoint_time, last_xlog_switch_time, LOG, LWLockReleaseAll(), MemoryContextReset(), MemoryContextSwitchTo(), Min, MyLatch, MyProcNumber, MyProcPid, now(), PgStat_CheckpointerStats::num_performed, PgStat_CheckpointerStats::num_requested, PgStat_CheckpointerStats::num_timed, PendingCheckpointerStats, PG_exception_stack, pg_usleep(), pgaio_error_cleanup(), pgstat_before_server_shutdown(), pgstat_report_checkpointer(), pgstat_report_wait_end(), pgstat_report_wal(), PMSIGNAL_XLOG_IS_SHUTDOWN, pqsignal, proc_exit(), ProcessCheckpointerInterrupts(), ProcGlobal, procsignal_sigusr1_handler(), RecoveryInProgress(), ReleaseAuxProcessResources(), ReqShutdownXLOG(), ResetLatch(), PgStat_CheckpointerStats::restartpoints_performed, PgStat_CheckpointerStats::restartpoints_requested, PgStat_CheckpointerStats::restartpoints_timed, RESUME_INTERRUPTS, SendPostmasterSignal(), ShutdownRequestPending, ShutdownXLOG(), ShutdownXLOGPending, SIGALRM, SIGCHLD, SIGHUP, SignalHandlerForConfigReload(), SignalHandlerForShutdownRequest(), SIGPIPE, SIGUSR1, SIGUSR2, smgrdestroyall(), SpinLockAcquire, SpinLockRelease, CheckpointerShmemStruct::start_cv, TopMemoryContext, UnBlockSig, UnlockBuffers(), UpdateSharedMemoryConfig(), WaitLatch(), WL_EXIT_ON_PM_DEATH, WL_LATCH_SET, WL_TIMEOUT, and XLogArchiveTimeout.

◆ CheckpointerShmemInit()

void CheckpointerShmemInit ( void  )
extern

Definition at line 978 of file checkpointer.c.

979{
981 bool found;
982
984 ShmemInitStruct("Checkpointer Data",
985 size,
986 &found);
987
988 if (!found)
989 {
990 /*
991 * First time through, so initialize. Note that we zero the whole
992 * requests array; this is so that CompactCheckpointerRequestQueue can
993 * assume that any pad bytes in the request structs are zeroes.
994 */
995 MemSet(CheckpointerShmem, 0, size);
1001 }
1002}
#define MemSet(start, val, len)
Definition c.h:1013
size_t Size
Definition c.h:619
#define MAX_CHECKPOINT_REQUESTS
Size CheckpointerShmemSize(void)
void ConditionVariableInit(ConditionVariable *cv)
int NBuffers
Definition globals.c:142
void * ShmemInitStruct(const char *name, Size size, bool *foundPtr)
Definition shmem.c:378
#define SpinLockInit(lock)
Definition spin.h:57

References CheckpointerShmem, CheckpointerShmemSize(), CheckpointerShmemStruct::ckpt_lck, ConditionVariableInit(), CheckpointerShmemStruct::done_cv, CheckpointerShmemStruct::head, MAX_CHECKPOINT_REQUESTS, CheckpointerShmemStruct::max_requests, MemSet, Min, NBuffers, ShmemInitStruct(), SpinLockInit, CheckpointerShmemStruct::start_cv, and CheckpointerShmemStruct::tail.

Referenced by CreateOrAttachShmemStructs().

◆ CheckpointerShmemSize()

Size CheckpointerShmemSize ( void  )
extern

Definition at line 956 of file checkpointer.c.

957{
958 Size size;
959
960 /*
961 * The size of the requests[] array is arbitrarily set equal to NBuffers.
962 * But there is a cap of MAX_CHECKPOINT_REQUESTS to prevent accumulating
963 * too many checkpoint requests in the ring buffer.
964 */
965 size = offsetof(CheckpointerShmemStruct, requests);
966 size = add_size(size, mul_size(Min(NBuffers,
968 sizeof(CheckpointerRequest)));
969
970 return size;
971}
Size add_size(Size s1, Size s2)
Definition shmem.c:482
Size mul_size(Size s1, Size s2)
Definition shmem.c:497

References add_size(), fb(), MAX_CHECKPOINT_REQUESTS, Min, mul_size(), and NBuffers.

Referenced by CalculateShmemSize(), and CheckpointerShmemInit().

◆ CheckpointWriteDelay()

void CheckpointWriteDelay ( int  flags,
double  progress 
)
extern

Definition at line 790 of file checkpointer.c.

791{
793
794 /* Do nothing if checkpoint is being executed by non-checkpointer process */
796 return;
797
798 /*
799 * Perform the usual duties and take a nap, unless we're behind schedule,
800 * in which case we just try to catch up as quickly as possible.
801 */
802 if (!(flags & CHECKPOINT_FAST) &&
807 {
809 {
810 ConfigReloadPending = false;
812 /* update shmem copies of config variables */
814 }
815
818
820
821 /* Report interim statistics to the cumulative stats system */
823
824 /*
825 * This sleep used to be connected to bgwriter_delay, typically 200ms.
826 * That resulted in more frequent wakeups if not much work to do.
827 * Checkpointer and bgwriter are no longer related so take the Big
828 * Sleep.
829 */
831 100,
834 }
835 else if (--absorb_counter <= 0)
836 {
837 /*
838 * Absorb pending fsync requests after each WRITES_PER_ABSORB write
839 * operations even when we don't sleep, to prevent overflow of the
840 * fsync request queue.
841 */
844 }
845
846 /* Check for barrier events. */
849}
static bool FastCheckpointRequested(void)
static bool IsCheckpointOnSchedule(double progress)
#define WRITES_PER_ABSORB
volatile sig_atomic_t ProcSignalBarrierPending
Definition globals.c:40
void ProcessConfigFile(GucContext context)
Definition guc-file.l:120
@ PGC_SIGHUP
Definition guc.h:75
volatile sig_atomic_t ConfigReloadPending
Definition interrupt.c:27
static int progress
Definition pgbench.c:262
void ProcessProcSignalBarrier(void)
Definition procsignal.c:499
#define CHECKPOINT_FAST
Definition xlog.h:152

References AbsorbSyncRequests(), AmCheckpointerProcess, CheckArchiveTimeout(), CHECKPOINT_FAST, ConfigReloadPending, FastCheckpointRequested(), fb(), IsCheckpointOnSchedule(), MyLatch, PGC_SIGHUP, pgstat_report_checkpointer(), ProcessConfigFile(), ProcessProcSignalBarrier(), ProcSignalBarrierPending, progress, ResetLatch(), ShutdownRequestPending, ShutdownXLOGPending, UpdateSharedMemoryConfig(), WaitLatch(), WL_EXIT_ON_PM_DEATH, WL_LATCH_SET, WL_TIMEOUT, and WRITES_PER_ABSORB.

Referenced by BufferSync().

◆ ExecCheckpoint()

void ExecCheckpoint ( ParseState pstate,
CheckPointStmt stmt 
)
extern

Definition at line 1011 of file checkpointer.c.

1012{
1013 bool fast = true;
1014 bool unlogged = false;
1015
1016 foreach_ptr(DefElem, opt, stmt->options)
1017 {
1018 if (strcmp(opt->defname, "mode") == 0)
1019 {
1020 char *mode = defGetString(opt);
1021
1022 if (strcmp(mode, "spread") == 0)
1023 fast = false;
1024 else if (strcmp(mode, "fast") != 0)
1025 ereport(ERROR,
1027 errmsg("unrecognized value for %s option \"%s\": \"%s\"",
1028 "CHECKPOINT", "mode", mode),
1029 parser_errposition(pstate, opt->location)));
1030 }
1031 else if (strcmp(opt->defname, "flush_unlogged") == 0)
1032 unlogged = defGetBoolean(opt);
1033 else
1034 ereport(ERROR,
1036 errmsg("unrecognized %s option \"%s\"",
1037 "CHECKPOINT", opt->defname),
1038 parser_errposition(pstate, opt->location)));
1039 }
1040
1042 ereport(ERROR,
1044 /* translator: %s is name of an SQL command (e.g., CHECKPOINT) */
1045 errmsg("permission denied to execute %s command",
1046 "CHECKPOINT"),
1047 errdetail("Only roles with privileges of the \"%s\" role may execute this command.",
1048 "pg_checkpoint")));
1049
1051 (fast ? CHECKPOINT_FAST : 0) |
1054}
bool has_privs_of_role(Oid member, Oid role)
Definition acl.c:5284
void RequestCheckpoint(int flags)
char * defGetString(DefElem *def)
Definition define.c:34
bool defGetBoolean(DefElem *def)
Definition define.c:93
int errdetail(const char *fmt,...)
Definition elog.c:1216
int errcode(int sqlerrcode)
Definition elog.c:863
int errmsg(const char *fmt,...)
Definition elog.c:1080
#define ERROR
Definition elog.h:39
#define stmt
Oid GetUserId(void)
Definition miscinit.c:469
int parser_errposition(ParseState *pstate, int location)
Definition parse_node.c:106
static PgChecksumMode mode
#define foreach_ptr(type, var, lst)
Definition pg_list.h:469
#define CHECKPOINT_FLUSH_UNLOGGED
Definition xlog.h:154
#define CHECKPOINT_FORCE
Definition xlog.h:153
#define CHECKPOINT_WAIT
Definition xlog.h:156

References CHECKPOINT_FAST, CHECKPOINT_FLUSH_UNLOGGED, CHECKPOINT_FORCE, CHECKPOINT_WAIT, defGetBoolean(), defGetString(), ereport, errcode(), errdetail(), errmsg(), ERROR, fb(), foreach_ptr, GetUserId(), has_privs_of_role(), mode, parser_errposition(), RecoveryInProgress(), RequestCheckpoint(), and stmt.

Referenced by standard_ProcessUtility().

◆ FirstCallSinceLastCheckpoint()

bool FirstCallSinceLastCheckpoint ( void  )
extern

Definition at line 1526 of file checkpointer.c.

1527{
1528 static int ckpt_done = 0;
1529 int new_done;
1530 bool FirstCall = false;
1531
1535
1536 if (new_done != ckpt_done)
1537 FirstCall = true;
1538
1539 ckpt_done = new_done;
1540
1541 return FirstCall;
1542}

References CheckpointerShmem, CheckpointerShmemStruct::ckpt_done, CheckpointerShmemStruct::ckpt_lck, fb(), SpinLockAcquire, and SpinLockRelease.

Referenced by BackgroundWriterMain().

◆ ForwardSyncRequest()

bool ForwardSyncRequest ( const FileTag ftag,
SyncRequestType  type 
)
extern

Definition at line 1224 of file checkpointer.c.

1225{
1227 bool too_full;
1228 int insert_pos;
1229
1230 if (!IsUnderPostmaster)
1231 return false; /* probably shouldn't even get here */
1232
1234 elog(ERROR, "ForwardSyncRequest must not be called in checkpointer");
1235
1237
1238 /*
1239 * If the checkpointer isn't running or the request queue is full, the
1240 * backend will have to perform its own fsync request. But before forcing
1241 * that to happen, we can try to compact the request queue.
1242 */
1246 {
1248 return false;
1249 }
1250
1251 /* OK, insert request */
1254 request->ftag = *ftag;
1255 request->type = type;
1256
1259
1260 /* If queue is more than half full, nudge the checkpointer to empty it */
1263
1265
1266 /* ... but not till after we release the lock */
1267 if (too_full)
1268 {
1269 volatile PROC_HDR *procglobal = ProcGlobal;
1270 ProcNumber checkpointerProc = procglobal->checkpointerProc;
1271
1272 if (checkpointerProc != INVALID_PROC_NUMBER)
1273 SetLatch(&GetPGProcByNumber(checkpointerProc)->procLatch);
1274 }
1275
1276 return true;
1277}
static bool CompactCheckpointerRequestQueue(void)
#define elog(elevel,...)
Definition elog.h:226
bool IsUnderPostmaster
Definition globals.c:120
void SetLatch(Latch *latch)
Definition latch.c:290
#define GetPGProcByNumber(n)
Definition proc.h:440
#define INVALID_PROC_NUMBER
Definition procnumber.h:26
int ProcNumber
Definition procnumber.h:24
const char * type

References AmCheckpointerProcess, CheckpointerShmemStruct::checkpointer_pid, PROC_HDR::checkpointerProc, CheckpointerShmem, CompactCheckpointerRequestQueue(), elog, ERROR, fb(), CheckpointerRequest::ftag, GetPGProcByNumber, INVALID_PROC_NUMBER, IsUnderPostmaster, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), CheckpointerShmemStruct::max_requests, CheckpointerShmemStruct::num_requests, ProcGlobal, CheckpointerShmemStruct::requests, SetLatch(), CheckpointerShmemStruct::tail, and type.

Referenced by RegisterSyncRequest().

◆ RequestCheckpoint()

void RequestCheckpoint ( int  flags)
extern

Definition at line 1074 of file checkpointer.c.

1075{
1076 int ntries;
1077 int old_failed,
1079
1080 /*
1081 * If in a standalone backend, just do it ourselves.
1082 */
1084 {
1085 /*
1086 * There's no point in doing slow checkpoints in a standalone backend,
1087 * because there's no other backends the checkpoint could disrupt.
1088 */
1090
1091 /* Free all smgr objects, as CheckpointerMain() normally would. */
1093
1094 return;
1095 }
1096
1097 /*
1098 * Atomically set the request flags, and take a snapshot of the counters.
1099 * When we see ckpt_started > old_started, we know the flags we set here
1100 * have been seen by checkpointer.
1101 *
1102 * Note that we OR the flags with any existing flags, to avoid overriding
1103 * a "stronger" request by another backend. The flag senses must be
1104 * chosen to make this work!
1105 */
1107
1111
1113
1114 /*
1115 * Set checkpointer's latch to request checkpoint. It's possible that the
1116 * checkpointer hasn't started yet, so we will retry a few times if
1117 * needed. (Actually, more than a few times, since on slow or overloaded
1118 * buildfarm machines, it's been observed that the checkpointer can take
1119 * several seconds to start.) However, if not told to wait for the
1120 * checkpoint to occur, we consider failure to set the latch to be
1121 * nonfatal and merely LOG it. The checkpointer should see the request
1122 * when it does start, with or without the SetLatch().
1123 */
1124#define MAX_SIGNAL_TRIES 600 /* max wait 60.0 sec */
1125 for (ntries = 0;; ntries++)
1126 {
1127 volatile PROC_HDR *procglobal = ProcGlobal;
1128 ProcNumber checkpointerProc = procglobal->checkpointerProc;
1129
1130 if (checkpointerProc == INVALID_PROC_NUMBER)
1131 {
1132 if (ntries >= MAX_SIGNAL_TRIES || !(flags & CHECKPOINT_WAIT))
1133 {
1134 elog((flags & CHECKPOINT_WAIT) ? ERROR : LOG,
1135 "could not notify checkpoint: checkpointer is not running");
1136 break;
1137 }
1138 }
1139 else
1140 {
1141 SetLatch(&GetPGProcByNumber(checkpointerProc)->procLatch);
1142 /* notified successfully */
1143 break;
1144 }
1145
1147 pg_usleep(100000L); /* wait 0.1 sec, then retry */
1148 }
1149
1150 /*
1151 * If requested, wait for completion. We detect completion according to
1152 * the algorithm given above.
1153 */
1154 if (flags & CHECKPOINT_WAIT)
1155 {
1156 int new_started,
1157 new_failed;
1158
1159 /* Wait for a new checkpoint to start. */
1161 for (;;)
1162 {
1166
1167 if (new_started != old_started)
1168 break;
1169
1172 }
1174
1175 /*
1176 * We are waiting for ckpt_done >= new_started, in a modulo sense.
1177 */
1179 for (;;)
1180 {
1181 int new_done;
1182
1187
1188 if (new_done - new_started >= 0)
1189 break;
1190
1193 }
1195
1196 if (new_failed != old_failed)
1197 ereport(ERROR,
1198 (errmsg("checkpoint request failed"),
1199 errhint("Consult recent messages in the server log for details.")));
1200 }
1201}
#define MAX_SIGNAL_TRIES
void ConditionVariablePrepareToSleep(ConditionVariable *cv)
void ConditionVariableSleep(ConditionVariable *cv, uint32 wait_event_info)
bool IsPostmasterEnvironment
Definition globals.c:119
#define CHECK_FOR_INTERRUPTS()
Definition miscadmin.h:123
#define CHECKPOINT_REQUESTED
Definition xlog.h:157

References CHECK_FOR_INTERRUPTS, CHECKPOINT_FAST, CHECKPOINT_REQUESTED, CHECKPOINT_WAIT, PROC_HDR::checkpointerProc, CheckpointerShmem, CheckpointerShmemStruct::ckpt_done, CheckpointerShmemStruct::ckpt_failed, CheckpointerShmemStruct::ckpt_flags, CheckpointerShmemStruct::ckpt_lck, CheckpointerShmemStruct::ckpt_started, ConditionVariableCancelSleep(), ConditionVariablePrepareToSleep(), ConditionVariableSleep(), CreateCheckPoint(), CheckpointerShmemStruct::done_cv, elog, ereport, errhint(), errmsg(), ERROR, fb(), GetPGProcByNumber, INVALID_PROC_NUMBER, IsPostmasterEnvironment, LOG, MAX_SIGNAL_TRIES, pg_usleep(), ProcGlobal, SetLatch(), smgrdestroyall(), SpinLockAcquire, SpinLockRelease, and CheckpointerShmemStruct::start_cv.

Referenced by CreateDatabaseUsingFileCopy(), do_pg_backup_start(), dropdb(), DropTableSpace(), ExecCheckpoint(), movedb(), PerformRecoveryXLogAction(), StartupXLOG(), XLogPageRead(), and XLogWrite().

Variable Documentation

◆ BgWriterDelay

PGDLLIMPORT int BgWriterDelay
extern

Definition at line 58 of file bgwriter.c.

Referenced by BackgroundWriterMain(), and BgBufferSync().

◆ CheckPointCompletionTarget

PGDLLIMPORT double CheckPointCompletionTarget
extern

◆ CheckPointTimeout

PGDLLIMPORT int CheckPointTimeout
extern

Definition at line 157 of file checkpointer.c.

Referenced by CheckpointerMain(), and IsCheckpointOnSchedule().

◆ CheckPointWarning

PGDLLIMPORT int CheckPointWarning
extern

Definition at line 158 of file checkpointer.c.

Referenced by CheckpointerMain().