131 #define WRITES_PER_ABSORB 1000
175 sigjmp_buf local_sigjmp_buf;
178 Assert(startup_data_len == 0);
251 if (sigsetjmp(local_sigjmp_buf, 1) != 0)
337 bool do_checkpoint =
false;
342 bool chkpt_or_rstpt_requested =
false;
343 bool chkpt_or_rstpt_timed =
false;
361 do_checkpoint =
true;
362 chkpt_or_rstpt_requested =
true;
376 chkpt_or_rstpt_timed =
true;
377 do_checkpoint =
true;
386 bool ckpt_performed =
false;
387 bool do_restartpoint;
410 do_restartpoint =
false;
412 if (chkpt_or_rstpt_timed)
414 chkpt_or_rstpt_timed =
false;
421 if (chkpt_or_rstpt_requested)
423 chkpt_or_rstpt_requested =
false;
437 if (!do_restartpoint &&
441 (
errmsg_plural(
"checkpoints are occurring too frequently (%d second apart)",
442 "checkpoints are occurring too frequently (%d seconds apart)",
445 errhint(
"Consider increasing the configuration parameter \"%s\".",
"max_wal_size")));
462 if (!do_restartpoint)
484 if (!do_restartpoint)
560 cur_timeout * 1000L ,
561 WAIT_EVENT_CHECKPOINTER_MAIN);
677 elog(
DEBUG1,
"write-ahead log switch forced (\"archive_timeout\"=%d)",
763 WAIT_EVENT_CHECKPOINT_WRITE_DELAY);
766 else if (--absorb_counter <= 0)
795 double elapsed_xlogs,
1002 #define MAX_SIGNAL_TRIES 600
1003 for (ntries = 0;; ntries++)
1010 "could not signal for checkpoint: checkpointer is not running");
1019 "could not signal for checkpoint: %m");
1047 if (new_started != old_started)
1051 WAIT_EVENT_CHECKPOINT_START);
1068 if (new_done - new_started >= 0)
1072 WAIT_EVENT_CHECKPOINT_DONE);
1076 if (new_failed != old_failed)
1078 (
errmsg(
"checkpoint request failed"),
1079 errhint(
"Consult recent messages in the server log for details.")));
1113 elog(
ERROR,
"ForwardSyncRequest must not be called in checkpointer");
1132 request->
ftag = *ftag;
1167 struct CheckpointerSlotMapping
1175 int num_skipped = 0;
1192 ctl.entrysize =
sizeof(
struct CheckpointerSlotMapping);
1195 htab =
hash_create(
"CompactCheckpointerRequestQueue",
1215 struct CheckpointerSlotMapping *slotmap;
1230 skip_slot[slotmap->slot] =
true;
1256 (
errmsg_internal(
"compacted fsync request queue from %d entries to %d entries",
1309 for (request = requests; n > 0; request++, n--)
1333 elog(
DEBUG2,
"checkpointer updated shared memory configuration values");
1343 static int ckpt_done = 0;
1345 bool FirstCall =
false;
1351 if (new_done != ckpt_done)
1354 ckpt_done = new_done;
void AuxiliaryProcessMainCommon(void)
Datum now(PG_FUNCTION_ARGS)
void AtEOXact_Buffers(bool isCommit)
#define Assert(condition)
#define FLEXIBLE_ARRAY_MEMBER
#define MemSet(start, val, len)
static void UpdateSharedMemoryConfig(void)
static XLogRecPtr ckpt_start_recptr
static bool ImmediateCheckpointRequested(void)
static bool IsCheckpointOnSchedule(double progress)
static void ReqCheckpointHandler(SIGNAL_ARGS)
bool ForwardSyncRequest(const FileTag *ftag, SyncRequestType type)
static void CheckArchiveTimeout(void)
void CheckpointerMain(char *startup_data, size_t startup_data_len)
static double ckpt_cached_elapsed
static bool CompactCheckpointerRequestQueue(void)
static void HandleCheckpointerInterrupts(void)
void AbsorbSyncRequests(void)
#define WRITES_PER_ABSORB
double CheckPointCompletionTarget
static pg_time_t last_xlog_switch_time
void CheckpointerShmemInit(void)
bool FirstCallSinceLastCheckpoint(void)
static CheckpointerShmemStruct * CheckpointerShmem
void RequestCheckpoint(int flags)
static pg_time_t last_checkpoint_time
void CheckpointWriteDelay(int flags, double progress)
static pg_time_t ckpt_start_time
Size CheckpointerShmemSize(void)
bool ConditionVariableCancelSleep(void)
void ConditionVariableBroadcast(ConditionVariable *cv)
void ConditionVariablePrepareToSleep(ConditionVariable *cv)
void ConditionVariableInit(ConditionVariable *cv)
void ConditionVariableSleep(ConditionVariable *cv, uint32 wait_event_info)
void AtEOXact_HashTables(bool isCommit)
void hash_destroy(HTAB *hashp)
void * hash_search(HTAB *hashp, const void *keyPtr, HASHACTION action, bool *foundPtr)
HTAB * hash_create(const char *tabname, long nelem, const HASHCTL *info, int flags)
int errmsg_plural(const char *fmt_singular, const char *fmt_plural, unsigned long n,...)
int errmsg_internal(const char *fmt,...)
void EmitErrorReport(void)
ErrorContextCallback * error_context_stack
void FlushErrorState(void)
int errhint(const char *fmt,...)
int errmsg(const char *fmt,...)
sigjmp_buf * PG_exception_stack
#define ereport(elevel,...)
static double elapsed_time(instr_time *starttime)
void AtEOXact_Files(bool isCommit)
volatile sig_atomic_t LogMemoryContextPending
volatile sig_atomic_t ProcSignalBarrierPending
volatile uint32 CritSectionCount
bool IsPostmasterEnvironment
void ProcessConfigFile(GucContext context)
void SignalHandlerForShutdownRequest(SIGNAL_ARGS)
volatile sig_atomic_t ShutdownRequestPending
volatile sig_atomic_t ConfigReloadPending
void SignalHandlerForConfigReload(SIGNAL_ARGS)
void before_shmem_exit(pg_on_exit_callback function, Datum arg)
void SetLatch(Latch *latch)
void ResetLatch(Latch *latch)
int WaitLatch(Latch *latch, int wakeEvents, long timeout, uint32 wait_event_info)
#define WL_EXIT_ON_PM_DEATH
bool LWLockHeldByMe(LWLock *lock)
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
void LWLockRelease(LWLock *lock)
void LWLockReleaseAll(void)
void MemoryContextReset(MemoryContext context)
void pfree(void *pointer)
MemoryContext TopMemoryContext
void * palloc0(Size size)
MemoryContext CurrentMemoryContext
void ProcessLogMemoryContextInterrupt(void)
#define AllocSetContextCreate
#define ALLOCSET_DEFAULT_SIZES
#define AmCheckpointerProcess()
#define RESUME_INTERRUPTS()
#define START_CRIT_SECTION()
#define CHECK_FOR_INTERRUPTS()
#define HOLD_INTERRUPTS()
#define END_CRIT_SECTION()
BackendType MyBackendType
void pgstat_before_server_shutdown(int code, Datum arg)
void pgstat_report_checkpointer(void)
PgStat_CheckpointerStats PendingCheckpointerStats
void pgstat_report_wal(bool force)
pqsigfunc pqsignal(int signo, pqsigfunc func)
void ProcessProcSignalBarrier(void)
void procsignal_sigusr1_handler(SIGNAL_ARGS)
MemoryContextSwitchTo(old_ctx)
void ReleaseAuxProcessResources(bool isCommit)
Size add_size(Size s1, Size s2)
void * ShmemInitStruct(const char *name, Size size, bool *foundPtr)
Size mul_size(Size s1, Size s2)
void pg_usleep(long microsec)
static pg_noinline void Size size
void smgrdestroyall(void)
#define SpinLockInit(lock)
#define SpinLockRelease(lock)
#define SpinLockAcquire(lock)
ConditionVariable done_cv
ConditionVariable start_cv
CheckpointerRequest requests[FLEXIBLE_ARRAY_MEMBER]
Latch * checkpointerLatch
PgStat_Counter restartpoints_requested
PgStat_Counter num_requested
PgStat_Counter num_performed
PgStat_Counter restartpoints_timed
PgStat_Counter restartpoints_performed
void RememberSyncRequest(const FileTag *ftag, SyncRequestType type)
void SyncRepUpdateSyncStandbysDefined(void)
static void pgstat_report_wait_end(void)
int gettimeofday(struct timeval *tp, void *tzp)
void UpdateFullPageWrites(void)
bool RecoveryInProgress(void)
XLogRecPtr RequestXLogSwitch(bool mark_unimportant)
bool CreateRestartPoint(int flags)
XLogRecPtr GetInsertRecPtr(void)
void ShutdownXLOG(int code, Datum arg)
pg_time_t GetLastSegSwitchData(XLogRecPtr *lastSwitchLSN)
XLogRecPtr GetLastImportantRecPtr(void)
bool CreateCheckPoint(int flags)
#define CHECKPOINT_CAUSE_XLOG
#define CHECKPOINT_END_OF_RECOVERY
#define CHECKPOINT_CAUSE_TIME
#define CHECKPOINT_REQUESTED
#define CHECKPOINT_IMMEDIATE
#define XLogSegmentOffset(xlogptr, wal_segsz_bytes)
XLogRecPtr GetXLogReplayRecPtr(TimeLineID *replayTLI)