MCPcopy Create free account
hub / github.com/apache/cloudberry / CheckpointWriteDelay

Function CheckpointWriteDelay

src/backend/postmaster/checkpointer.c:705–766  ·  view source on GitHub ↗

* CheckpointWriteDelay -- control rate 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. * * 'progr

Source from the content-addressed store, hash-verified

703 * fraction between 0.0 meaning none, and 1.0 meaning all done.
704 */
705void
706CheckpointWriteDelay(int flags, double progress)
707{
708 static int absorb_counter = WRITES_PER_ABSORB;
709
710 /* Do nothing if checkpoint is being executed by non-checkpointer process */
711 if (!AmCheckpointerProcess())
712 return;
713
714 /*
715 * Perform the usual duties and take a nap, unless we're behind schedule,
716 * in which case we just try to catch up as quickly as possible.
717 */
718 if (!(flags & CHECKPOINT_IMMEDIATE) &&
719 !ShutdownRequestPending &&
720 !ImmediateCheckpointRequested() &&
721 IsCheckpointOnSchedule(progress))
722 {
723 if (ConfigReloadPending)
724 {
725 ConfigReloadPending = false;
726 ProcessConfigFile(PGC_SIGHUP);
727 /* update shmem copies of config variables */
728 UpdateSharedMemoryConfig();
729 }
730
731 AbsorbSyncRequests();
732 absorb_counter = WRITES_PER_ABSORB;
733
734 CheckArchiveTimeout();
735
736 /*
737 * Report interim activity statistics to the stats collector.
738 */
739 pgstat_send_bgwriter();
740
741 /*
742 * This sleep used to be connected to bgwriter_delay, typically 200ms.
743 * That resulted in more frequent wakeups if not much work to do.
744 * Checkpointer and bgwriter are no longer related so take the Big
745 * Sleep.
746 */
747 WaitLatch(MyLatch, WL_LATCH_SET | WL_EXIT_ON_PM_DEATH | WL_TIMEOUT,
748 100,
749 WAIT_EVENT_CHECKPOINT_WRITE_DELAY);
750 ResetLatch(MyLatch);
751 }
752 else if (--absorb_counter <= 0)
753 {
754 /*
755 * Absorb pending fsync requests after each WRITES_PER_ABSORB write
756 * operations even when we don't sleep, to prevent overflow of the
757 * fsync request queue.
758 */
759 AbsorbSyncRequests();
760 absorb_counter = WRITES_PER_ABSORB;
761 }
762

Callers 1

BufferSyncFunction · 0.85

Calls 9

IsCheckpointOnScheduleFunction · 0.85
UpdateSharedMemoryConfigFunction · 0.85
AbsorbSyncRequestsFunction · 0.85
CheckArchiveTimeoutFunction · 0.85
pgstat_send_bgwriterFunction · 0.85
WaitLatchFunction · 0.85
ResetLatchFunction · 0.85
ProcessProcSignalBarrierFunction · 0.85

Tested by

no test coverage detected