PostgreSQL Source Code
git master
|
#include "postgres.h"
#include <sys/time.h>
#include "access/xlog.h"
#include "access/xlog_internal.h"
#include "libpq/pqsignal.h"
#include "miscadmin.h"
#include "pgstat.h"
#include "postmaster/bgwriter.h"
#include "postmaster/interrupt.h"
#include "replication/syncrep.h"
#include "storage/bufmgr.h"
#include "storage/condition_variable.h"
#include "storage/fd.h"
#include "storage/ipc.h"
#include "storage/lwlock.h"
#include "storage/proc.h"
#include "storage/procsignal.h"
#include "storage/shmem.h"
#include "storage/smgr.h"
#include "storage/spin.h"
#include "utils/guc.h"
#include "utils/memutils.h"
#include "utils/resowner.h"
Go to the source code of this file.
Data Structures | |
struct | CheckpointerRequest |
struct | CheckpointerShmemStruct |
Macros | |
#define | WRITES_PER_ABSORB 1000 |
#define | MAX_SIGNAL_TRIES 600 /* max wait 60.0 sec */ |
Functions | |
static void | HandleCheckpointerInterrupts (void) |
static void | CheckArchiveTimeout (void) |
static bool | IsCheckpointOnSchedule (double progress) |
static bool | ImmediateCheckpointRequested (void) |
static bool | CompactCheckpointerRequestQueue (void) |
static void | UpdateSharedMemoryConfig (void) |
static void | ReqCheckpointHandler (SIGNAL_ARGS) |
void | CheckpointerMain (void) |
void | CheckpointWriteDelay (int flags, double progress) |
Size | CheckpointerShmemSize (void) |
void | CheckpointerShmemInit (void) |
void | RequestCheckpoint (int flags) |
bool | ForwardSyncRequest (const FileTag *ftag, SyncRequestType type) |
void | AbsorbSyncRequests (void) |
bool | FirstCallSinceLastCheckpoint (void) |
Variables | |
static CheckpointerShmemStruct * | CheckpointerShmem |
int | CheckPointTimeout = 300 |
int | CheckPointWarning = 30 |
double | CheckPointCompletionTarget = 0.9 |
static bool | ckpt_active = false |
static pg_time_t | ckpt_start_time |
static XLogRecPtr | ckpt_start_recptr |
static double | ckpt_cached_elapsed |
static pg_time_t | last_checkpoint_time |
static pg_time_t | last_xlog_switch_time |
#define MAX_SIGNAL_TRIES 600 /* max wait 60.0 sec */ |
Referenced by RequestCheckpoint().
#define WRITES_PER_ABSORB 1000 |
Definition at line 141 of file checkpointer.c.
Referenced by CheckpointWriteDelay().
void AbsorbSyncRequests | ( | void | ) |
Definition at line 1259 of file checkpointer.c.
References AmCheckpointerProcess, BgWriterStats, END_CRIT_SECTION, CheckpointerRequest::ftag, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), PgStat_MsgBgWriter::m_buf_fsync_backend, PgStat_MsgBgWriter::m_buf_written_backend, CheckpointerShmemStruct::num_backend_fsync, CheckpointerShmemStruct::num_backend_writes, CheckpointerShmemStruct::num_requests, palloc(), pfree(), RememberSyncRequest(), CheckpointerShmemStruct::requests, START_CRIT_SECTION, and CheckpointerRequest::type.
Referenced by CheckpointerMain(), CheckpointWriteDelay(), ProcessSyncRequests(), and SyncPostCheckpoint().
|
static |
Definition at line 606 of file checkpointer.c.
References DEBUG1, elog, GetLastImportantRecPtr(), GetLastSegSwitchData(), last_xlog_switch_time, Max, now(), RecoveryInProgress(), RequestXLogSwitch(), wal_segment_size, XLogArchiveTimeout, and XLogSegmentOffset.
Referenced by CheckpointerMain(), and CheckpointWriteDelay().
void CheckpointerMain | ( | void | ) |
Definition at line 183 of file checkpointer.c.
References AbortBufferIO(), AbsorbSyncRequests(), ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, AtEOXact_Buffers(), AtEOXact_Files(), AtEOXact_HashTables(), AtEOXact_SMgr(), BgWriterStats, CheckArchiveTimeout(), CHECKPOINT_CAUSE_TIME, CHECKPOINT_CAUSE_XLOG, CHECKPOINT_END_OF_RECOVERY, CheckpointerShmemStruct::checkpointer_pid, PROC_HDR::checkpointerLatch, 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(), CheckpointerShmemStruct::done_cv, EmitErrorReport(), ereport, errhint(), errmsg_plural(), error_context_stack, FlushErrorState(), GetInsertRecPtr(), GetXLogReplayRecPtr(), HandleCheckpointerInterrupts(), HOLD_INTERRUPTS, last_checkpoint_time, last_xlog_switch_time, LOG, LWLockReleaseAll(), PgStat_MsgBgWriter::m_requested_checkpoints, PgStat_MsgBgWriter::m_timed_checkpoints, MemoryContextResetAndDeleteChildren, MemoryContextSwitchTo(), Min, MyLatch, MyProc, MyProcPid, now(), PG_exception_stack, PG_SETMASK, pg_usleep(), pgstat_report_wait_end(), pgstat_report_wal(), pgstat_send_bgwriter(), pqsignal(), ProcGlobal, PGPROC::procLatch, procsignal_sigusr1_handler(), RecoveryInProgress(), ReleaseAuxProcessResources(), ReqCheckpointHandler(), ResetLatch(), RESUME_INTERRUPTS, SIG_DFL, SIG_IGN, SIGALRM, SIGCHLD, SIGHUP, SignalHandlerForConfigReload(), SignalHandlerForShutdownRequest(), SIGPIPE, SIGUSR1, SIGUSR2, smgrcloseall(), SpinLockAcquire, SpinLockRelease, CheckpointerShmemStruct::start_cv, TopMemoryContext, UnBlockSig, UnlockBuffers(), UpdateSharedMemoryConfig(), WAIT_EVENT_CHECKPOINTER_MAIN, WaitLatch(), WL_EXIT_ON_PM_DEATH, WL_LATCH_SET, WL_TIMEOUT, and XLogArchiveTimeout.
Referenced by AuxiliaryProcessMain().
void CheckpointerShmemInit | ( | void | ) |
Definition at line 884 of file checkpointer.c.
References CheckpointerShmemSize(), CheckpointerShmemStruct::ckpt_lck, ConditionVariableInit(), CheckpointerShmemStruct::done_cv, CheckpointerShmemStruct::max_requests, MemSet, NBuffers, ShmemInitStruct(), SpinLockInit, and CheckpointerShmemStruct::start_cv.
Referenced by CreateSharedMemoryAndSemaphores().
Size CheckpointerShmemSize | ( | void | ) |
Definition at line 865 of file checkpointer.c.
References add_size(), mul_size(), NBuffers, and offsetof.
Referenced by CheckpointerShmemInit(), and CreateSharedMemoryAndSemaphores().
void CheckpointWriteDelay | ( | int | flags, |
double | progress | ||
) |
Definition at line 694 of file checkpointer.c.
References AbsorbSyncRequests(), AmCheckpointerProcess, CheckArchiveTimeout(), CHECKPOINT_IMMEDIATE, ConfigReloadPending, ImmediateCheckpointRequested(), IsCheckpointOnSchedule(), pg_usleep(), PGC_SIGHUP, pgstat_send_bgwriter(), ProcessConfigFile(), ProcessProcSignalBarrier(), ProcSignalBarrierPending, ShutdownRequestPending, UpdateSharedMemoryConfig(), and WRITES_PER_ABSORB.
Referenced by BufferSync().
|
static |
Definition at line 1153 of file checkpointer.c.
References Assert, CurrentMemoryContext, DEBUG1, HASHCTL::entrysize, ereport, errmsg_internal(), HASH_BLOBS, HASH_CONTEXT, hash_create(), hash_destroy(), HASH_ELEM, HASH_ENTER, hash_search(), HASHCTL::hcxt, HASHCTL::keysize, LWLockHeldByMe(), CheckpointerShmemStruct::num_requests, palloc0(), pfree(), and CheckpointerShmemStruct::requests.
Referenced by ForwardSyncRequest().
bool FirstCallSinceLastCheckpoint | ( | void | ) |
Definition at line 1332 of file checkpointer.c.
References CheckpointerShmemStruct::ckpt_done, CheckpointerShmemStruct::ckpt_lck, SpinLockAcquire, and SpinLockRelease.
Referenced by BackgroundWriterMain().
bool ForwardSyncRequest | ( | const FileTag * | ftag, |
SyncRequestType | type | ||
) |
Definition at line 1082 of file checkpointer.c.
References AmBackgroundWriterProcess, AmCheckpointerProcess, CheckpointerShmemStruct::checkpointer_pid, PROC_HDR::checkpointerLatch, CompactCheckpointerRequestQueue(), elog, ERROR, CheckpointerRequest::ftag, IsUnderPostmaster, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), CheckpointerShmemStruct::max_requests, CheckpointerShmemStruct::num_backend_fsync, CheckpointerShmemStruct::num_backend_writes, CheckpointerShmemStruct::num_requests, ProcGlobal, CheckpointerShmemStruct::requests, SetLatch(), CheckpointerRequest::type, and generate_unaccent_rules::type.
Referenced by RegisterSyncRequest().
|
static |
Definition at line 545 of file checkpointer.c.
References BgWriterStats, ConfigReloadPending, ExitOnAnyError, PgStat_MsgBgWriter::m_requested_checkpoints, PGC_SIGHUP, pgstat_report_wal(), pgstat_send_bgwriter(), proc_exit(), ProcessConfigFile(), ProcessProcSignalBarrier(), ProcSignalBarrierPending, ShutdownRequestPending, ShutdownXLOG(), and UpdateSharedMemoryConfig().
Referenced by CheckpointerMain().
|
static |
Definition at line 667 of file checkpointer.c.
References CHECKPOINT_IMMEDIATE, CheckpointerShmem, and CheckpointerShmemStruct::ckpt_flags.
Referenced by CheckpointWriteDelay().
|
static |
Definition at line 762 of file checkpointer.c.
References Assert, CheckPointCompletionTarget, CheckPointSegments, CheckPointTimeout, ckpt_active, ckpt_cached_elapsed, ckpt_start_recptr, ckpt_start_time, elapsed_time(), GetInsertRecPtr(), gettimeofday(), GetXLogReplayRecPtr(), RecoveryInProgress(), and wal_segment_size.
Referenced by CheckpointWriteDelay().
|
static |
Definition at line 841 of file checkpointer.c.
References MyLatch, and SetLatch().
Referenced by CheckpointerMain().
void RequestCheckpoint | ( | int | flags | ) |
Definition at line 927 of file checkpointer.c.
References CHECK_FOR_INTERRUPTS, CHECKPOINT_IMMEDIATE, CHECKPOINT_REQUESTED, CHECKPOINT_WAIT, CheckpointerShmemStruct::checkpointer_pid, 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, IsPostmasterEnvironment, kill, LOG, MAX_SIGNAL_TRIES, pg_usleep(), smgrcloseall(), SpinLockAcquire, SpinLockRelease, CheckpointerShmemStruct::start_cv, WAIT_EVENT_CHECKPOINT_DONE, and WAIT_EVENT_CHECKPOINT_START.
Referenced by createdb(), do_pg_start_backup(), dropdb(), DropTableSpace(), movedb(), standard_ProcessUtility(), StartupXLOG(), XLogPageRead(), and XLogWrite().
|
static |
Definition at line 1313 of file checkpointer.c.
References DEBUG2, elog, SyncRepUpdateSyncStandbysDefined(), and UpdateFullPageWrites().
Referenced by CheckpointerMain(), CheckpointWriteDelay(), and HandleCheckpointerInterrupts().
double CheckPointCompletionTarget = 0.9 |
Definition at line 148 of file checkpointer.c.
Referenced by assign_checkpoint_completion_target(), CalculateCheckpointSegments(), IsCheckpointOnSchedule(), and XLOGfileslop().
|
static |
Definition at line 138 of file checkpointer.c.
Referenced by ImmediateCheckpointRequested().
int CheckPointTimeout = 300 |
Definition at line 146 of file checkpointer.c.
Referenced by CheckpointerMain(), and IsCheckpointOnSchedule().
int CheckPointWarning = 30 |
Definition at line 147 of file checkpointer.c.
Referenced by CheckpointerMain().
Definition at line 153 of file checkpointer.c.
Referenced by CheckpointerMain(), and IsCheckpointOnSchedule().
|
static |
Definition at line 158 of file checkpointer.c.
Referenced by CheckpointerMain(), and IsCheckpointOnSchedule().
|
static |
Definition at line 157 of file checkpointer.c.
Referenced by CheckpointerMain(), and IsCheckpointOnSchedule().
|
static |
Definition at line 156 of file checkpointer.c.
Referenced by CheckpointerMain(), and IsCheckpointOnSchedule().
|
static |
Definition at line 160 of file checkpointer.c.
Referenced by CheckpointerMain().
|
static |
Definition at line 161 of file checkpointer.c.
Referenced by CheckArchiveTimeout(), and CheckpointerMain().