In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces "what is the function used to control the frequency of brushing disk in checkpoint". In the daily operation, I believe that many people have doubts about the function used to control the frequency of brushing disk in checkpoint. The editor consulted all kinds of data and sorted out a simple and easy-to-use operation method. I hope it will be helpful to answer the question of "what is the function used to control the frequency of brushing disk in checkpoint". Next, please follow the editor to study!
I. data structure
Macro definition
Checkpoints request flag bits
Checkpoints request flag bits, checkpoint request tag bit definition.
/ * OR-able request flag bits for checkpoints. The "cause" bits are used only * for logging purposes. Note: the flags must be defined so that it's * sensible to OR together request flags arising from different requestors. * / / * These directly affect the behavior of CreateCheckPoint and subsidiaries * / # define CHECKPOINT_IS_SHUTDOWN 0x0001 / * Checkpoint is for shutdown * / # define CHECKPOINT_END_OF_RECOVERY 0x0002 / * Like shutdown checkpoint, but * issued at end of WAL recovery * / # define CHECKPOINT_IMMEDIATE 0x0004 / * Do it without delays * / # define CHECKPOINT_FORCE 0x0008 / * Force even if no activity * / # define CHECKPOINT_FLUSH_ALL 0x0010 / * Flush all pages Including those * belonging to unlogged tables * / / * These are important to RequestCheckpoint * / # define CHECKPOINT_WAIT 0x0020 / * Wait for completion * / # define CHECKPOINT_REQUESTED 0x0040 / * Checkpoint request has been made * / / * These indicate the cause of a checkpoint request * / # define CHECKPOINT_CAUSE_XLOG 0x0080 / * XLOG consumption * / # define CHECKPOINT_CAUSE_TIME 0x0100 / * Elapsed time * /
WRITES_PER_ABSORB
/ * interval for calling AbsorbSyncRequests in CheckpointWriteDelay * / / interval between calls to AbsorbSyncRequests. Default is 1000#define WRITES_PER_ABSORB 1000. II. Source code interpretation
CheckpointWriteDelay
CheckpointWriteDelay, control the frequency of checkpoint, the logic is not complicated, judge checkpoint flags non-CHECKPOINT_IMMEDIATE/ non-shutdown _ requested/ non-checkpoint _ IMMEDIATE and checkpoint is in scheduling, if the above conditions are satisfied, then call AbsorbSyncRequests to process sync and sleep 100ms; if the above conditions are not satisfied, then the absorb_counter counter is minus one, if the counter AbsorbSyncRequests 0, then call AbsorbSyncRequests to deal with sync.
/ * * CheckpointWriteDelay-- control rate of checkpoint * controls the frequency of checkpoint * * This function is called after each page write performed by BufferSync (). * It is responsible for throttling BufferSync ()'s write rate to hit * checkpoint_completion_target. * * The checkpoint request flags should be passed in; currently the only one * examined is CHECKPOINT_IMMEDIATE, which disables delays between writes. * 'progress' is an estimate of how much of the work has been done, as a * fraction between 0.0 meaning none, and 1.0 meaning all done. * / voidCheckpointWriteDelay (int flags, double progress) {static int absorb_counter = WRITES_PER_ABSORB; / * Do nothing if checkpoint is being executed by non-checkpointer process * / if (! AmCheckpointerProcess ()) return; / * Perform the usual duties and take a nap, unless we're behind schedule, * in which case we just try to catch up as quickly as possible. * / if (! (flags & CHECKPOINT_IMMEDIATE) & & / / non-checkpoint _ IMMEDIATE! shutdown_requested & & / / unclosed request! ImmediateCheckpointRequested () & & / / non-checkpoint _ IMMEDIATE IsCheckpointOnSchedule (progress)) / / in checkpoint scheduling {if (got_SIGHUP) {got_SIGHUP = false; ProcessConfigFile (PGC_SIGHUP); / * update shmem copies of config variables * / UpdateSharedMemoryConfig () } / / Absorb absorbs (processes) synchronous request AbsorbSyncRequests (); / / resets to WRITES_PER_ABSORB (1000) absorb_counter = WRITES_PER_ABSORB; / / check whether the archive timed out CheckArchiveTimeout (); / * Report interim activity statistics to the stats collector. * / / Statistics pgstat_send_bgwriter (); / * * This sleep used to be connected to bgwriter_delay, typically 200ms. * That resulted in more frequent wakeups if not much work to do. * Checkpointer and bgwriter are no longer related so take the Big * Sleep. * / / hibernating 100ms pg_usleep (100000L);} else if (--absorb_counter
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.