From 559efce1d684069acf234a5cb032acba84e70938 Mon Sep 17 00:00:00 2001 From: Fujii Masao Date: Mon, 30 Sep 2024 11:56:05 +0900 Subject: Add num_done counter to the pg_stat_checkpointer view. Checkpoints can be skipped when the server is idle. The existing num_timed and num_requested counters in pg_stat_checkpointer track both completed and skipped checkpoints, but there was no way to count only the completed ones. This commit introduces the num_done counter, which tracks only completed checkpoints, making it easier to see how many were actually performed. Bump catalog version. Author: Anton A. Melnikov Reviewed-by: Fujii Masao Discussion: https://postgr.es/m/9ea77f40-818d-4841-9dee-158ac8f6e690@oss.nttdata.com --- src/backend/access/transam/xlog.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/backend/access/transam/xlog.c') diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 853ab06812b..64304d77d37 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -6878,8 +6878,11 @@ update_checkpoint_display(int flags, bool restartpoint, bool reset) * In this case, we only insert an XLOG_CHECKPOINT_SHUTDOWN record, and it's * both the record marking the completion of the checkpoint and the location * from which WAL replay would begin if needed. + * + * Returns true if a new checkpoint was performed, or false if it was skipped + * because the system was idle. */ -void +bool CreateCheckPoint(int flags) { bool shutdown; @@ -6971,7 +6974,7 @@ CreateCheckPoint(int flags) END_CRIT_SECTION(); ereport(DEBUG1, (errmsg_internal("checkpoint skipped because system is idle"))); - return; + return false; } } @@ -7353,6 +7356,8 @@ CreateCheckPoint(int flags) CheckpointStats.ckpt_segs_added, CheckpointStats.ckpt_segs_removed, CheckpointStats.ckpt_segs_recycled); + + return true; } /* -- cgit v1.2.3