139 #define WRITES_PER_ABSORB 1000
194 sigjmp_buf local_sigjmp_buf;
258 if (sigsetjmp(local_sigjmp_buf, 1) != 0)
353 bool do_checkpoint =
false;
389 do_checkpoint =
true;
417 do_checkpoint =
true;
426 bool ckpt_performed =
false;
427 bool do_restartpoint;
452 do_restartpoint =
false;
461 if (!do_restartpoint &&
465 (
errmsg_plural(
"checkpoints are occurring too frequently (%d second apart)",
466 "checkpoints are occurring too frequently (%d seconds apart)",
469 errhint(
"Consider increasing the configuration parameter \"max_wal_size\".")));
486 if (!do_restartpoint)
489 ckpt_performed =
true;
514 last_checkpoint_time =
now;
561 cur_timeout * 1000L );
616 (
errmsg(
"transaction log switch forced (archive_timeout=%d)",
706 else if (--absorb_counter <= 0)
731 double elapsed_xlogs,
774 if (progress < elapsed_xlogs)
787 if (progress < elapsed_time)
839 int save_errno = errno;
851 int save_errno = errno;
863 int save_errno = errno;
874 int save_errno = errno;
929 MemSet(CheckpointerShmem, 0, size);
1003 for (ntries = 0;; ntries++)
1010 "could not request checkpoint because checkpointer not running");
1019 "could not signal for checkpoint: %m");
1046 if (new_started != old_started)
1061 new_done = CheckpointerShmem->
ckpt_done;
1065 if (new_done - new_started >= 0)
1072 if (new_failed != old_failed)
1074 (
errmsg(
"checkpoint request failed"),
1075 errhint(
"Consult recent messages in the server log for details.")));
1118 elog(
ERROR,
"ForwardFsyncRequest must not be called in checkpointer");
1147 request->
rnode = rnode;
1149 request->
segno = segno;
1183 struct CheckpointerSlotMapping
1191 int num_skipped = 0;
1203 MemSet(&ctl, 0,
sizeof(ctl));
1205 ctl.
entrysize =
sizeof(
struct CheckpointerSlotMapping);
1208 htab =
hash_create(
"CompactCheckpointerRequestQueue",
1229 struct CheckpointerSlotMapping *slotmap;
1239 request = &CheckpointerShmem->
requests[n];
1244 skip_slot[slotmap->slot] =
true;
1267 CheckpointerShmem->
requests[preserve_count++] = CheckpointerShmem->
requests[n];
1270 (
errmsg(
"compacted fsync request queue from %d entries to %d entries",
1330 for (request = requests; n > 0; request++, n--)
1354 elog(
DEBUG2,
"checkpointer updated shared memory configuration values");
1364 static int ckpt_done = 0;
1366 bool FirstCall =
false;
1369 new_done = CheckpointerShmem->
ckpt_done;
1372 if (new_done != ckpt_done)
1375 ckpt_done = new_done;
void RememberFsyncRequest(RelFileNode rnode, ForkNumber forknum, BlockNumber segno)
PgStat_Counter m_buf_fsync_backend
void SyncRepUpdateSyncStandbysDefined(void)
bool IsPostmasterEnvironment
void CheckpointWriteDelay(int flags, double progress)
void hash_destroy(HTAB *hashp)
static bool IsCheckpointOnSchedule(double progress)
int gettimeofday(struct timeval *tp, struct timezone *tzp)
XLogRecPtr GetInsertRecPtr(void)
int errhint(const char *fmt,...)
void ProcessConfigFile(GucContext context)
static void ReqCheckpointHandler(SIGNAL_ARGS)
bool LWLockHeldByMe(LWLock *l)
int errmsg_plural(const char *fmt_singular, const char *fmt_plural, unsigned long n,...)
bool ForwardFsyncRequest(RelFileNode rnode, ForkNumber forknum, BlockNumber segno)
void CreateCheckPoint(int flags)
PgStat_Counter m_timed_checkpoints
void AtEOXact_Buffers(bool isCommit)
ResourceOwner CurrentResourceOwner
#define SpinLockInit(lock)
#define END_CRIT_SECTION()
bool CreateRestartPoint(int flags)
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
void CheckpointerShmemInit(void)
PgStat_MsgBgWriter BgWriterStats
CheckpointerRequest requests[FLEXIBLE_ARRAY_MEMBER]
#define START_CRIT_SECTION()
#define MemSet(start, val, len)
void * hash_search(HTAB *hashp, const void *keyPtr, HASHACTION action, bool *foundPtr)
void ResetLatch(volatile Latch *latch)
bool RecoveryInProgress(void)
void FlushErrorState(void)
#define ALLOCSET_DEFAULT_MINSIZE
void LWLockRelease(LWLock *lock)
#define RESUME_INTERRUPTS()
ErrorContextCallback * error_context_stack
#define CHECKPOINT_CAUSE_XLOG
PgStat_Counter m_requested_checkpoints
#define SpinLockAcquire(lock)
static bool ImmediateCheckpointRequested(void)
void pg_usleep(long microsec)
void pfree(void *pointer)
#define AmBackgroundWriterProcess()
pg_time_t GetLastSegSwitchTime(void)
#define AmCheckpointerProcess()
void * ShmemInitStruct(const char *name, Size size, bool *foundPtr)
void AtEOXact_Files(void)
static bool CompactCheckpointerRequestQueue(void)
XLogRecPtr GetXLogReplayRecPtr(TimeLineID *replayTLI)
static void ChkptSigHupHandler(SIGNAL_ARGS)
#define CHECKPOINT_END_OF_RECOVERY
static void pgstat_report_wait_end(void)
MemoryContext CurrentMemoryContext
#define ereport(elevel, rest)
MemoryContext TopMemoryContext
static CheckpointerShmemStruct * CheckpointerShmem
void ShutdownXLOG(int code, Datum arg)
#define MemoryContextResetAndDeleteChildren(ctx)
#define SpinLockRelease(lock)
static void UpdateSharedMemoryConfig(void)
Size mul_size(Size s1, Size s2)
#define WL_POSTMASTER_DEATH
void UpdateFullPageWrites(void)
MemoryContext AllocSetContextCreate(MemoryContext parent, const char *name, Size minContextSize, Size initBlockSize, Size maxBlockSize)
void * palloc0(Size size)
bool FirstCallSinceLastCheckpoint(void)
HTAB * hash_create(const char *tabname, long nelem, HASHCTL *info, int flags)
Size add_size(Size s1, Size s2)
#define WRITES_PER_ABSORB
static void chkpt_quickdie(SIGNAL_ARGS)
Size CheckpointerShmemSize(void)
void EmitErrorReport(void)
static pg_time_t last_xlog_switch_time
void pgstat_send_bgwriter(void)
uint32 num_backend_writes
void CheckpointerMain(void)
static pg_time_t ckpt_start_time
static volatile sig_atomic_t got_SIGHUP
pqsigfunc pqsignal(int signum, pqsigfunc handler)
static XLogRecPtr ckpt_start_recptr
Latch * checkpointerLatch
void SetLatch(volatile Latch *latch)
#define Assert(condition)
void ResourceOwnerRelease(ResourceOwner owner, ResourceReleasePhase phase, bool isCommit, bool isTopLevel)
PgStat_Counter m_buf_written_backend
static void ReqShutdownHandler(SIGNAL_ARGS)
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
static double elapsed_time(instr_time *starttime)
sigjmp_buf * PG_exception_stack
static volatile sig_atomic_t checkpoint_requested
int WaitLatch(volatile Latch *latch, int wakeEvents, long timeout)
int errmsg(const char *fmt,...)
static double ckpt_cached_elapsed
static void CheckArchiveTimeout(void)
#define HOLD_INTERRUPTS()
#define ALLOCSET_DEFAULT_INITSIZE
#define CHECKPOINT_CAUSE_TIME
#define CHECKPOINT_IMMEDIATE
#define ALLOCSET_DEFAULT_MAXSIZE
#define CHECK_FOR_INTERRUPTS()
void LWLockReleaseAll(void)
void latch_sigusr1_handler(void)
void AbsorbFsyncRequests(void)
void AtEOXact_HashTables(bool isCommit)
static void chkpt_sigusr1_handler(SIGNAL_ARGS)
static pg_time_t last_checkpoint_time
XLogRecPtr RequestXLogSwitch(void)
Datum now(PG_FUNCTION_ARGS)
static volatile sig_atomic_t shutdown_requested
#define offsetof(type, field)
void RequestCheckpoint(int flags)
double CheckPointCompletionTarget
ResourceOwner ResourceOwnerCreate(ResourceOwner parent, const char *name)