summaryrefslogtreecommitdiff
path: root/src/backend/postmaster/checkpointer.c
diff options
context:
space:
mode:
authorAndres Freund <andres@anarazel.de>2021-08-04 19:16:04 -0700
committerAndres Freund <andres@anarazel.de>2021-08-04 19:16:04 -0700
commit1bc8e7b0991c1eae5fa6dc2d29bb2280efb52740 (patch)
treea1648b9a8353e9405536c7298f44558407b9e70f /src/backend/postmaster/checkpointer.c
parentcc8033e1dafe89271aa86c2f2f86a828956929f0 (diff)
pgstat: split reporting/fetching of bgwriter and checkpointer stats.
These have been unrelated since bgwriter and checkpointer were split into two processes in 806a2aee379. As there several pending patches (shared memory stats, extending the set of tracked IO / buffer statistics) that are made a bit more awkward by the grouping, split them. Done separately to make reviewing easier. This does *not* change the contents of pg_stat_bgwriter or move fields out of bgwriter/checkpointer stats that arguably do not belong in either. However pgstat_fetch_global() was renamed and split into pgstat_fetch_stat_checkpointer() and pgstat_fetch_stat_bgwriter(). Author: Andres Freund <andres@anarazel.de> Discussion: https://postgr.es/m/20210405092914.mmxqe7j56lsjfsej@alap3.anarazel.de
Diffstat (limited to 'src/backend/postmaster/checkpointer.c')
-rw-r--r--src/backend/postmaster/checkpointer.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/src/backend/postmaster/checkpointer.c b/src/backend/postmaster/checkpointer.c
index bc9ac7ccfaf..be7366379d0 100644
--- a/src/backend/postmaster/checkpointer.c
+++ b/src/backend/postmaster/checkpointer.c
@@ -357,7 +357,7 @@ CheckpointerMain(void)
if (((volatile CheckpointerShmemStruct *) CheckpointerShmem)->ckpt_flags)
{
do_checkpoint = true;
- BgWriterStats.m_requested_checkpoints++;
+ PendingCheckpointerStats.m_requested_checkpoints++;
}
/*
@@ -371,7 +371,7 @@ CheckpointerMain(void)
if (elapsed_secs >= CheckPointTimeout)
{
if (!do_checkpoint)
- BgWriterStats.m_timed_checkpoints++;
+ PendingCheckpointerStats.m_timed_checkpoints++;
do_checkpoint = true;
flags |= CHECKPOINT_CAUSE_TIME;
}
@@ -493,13 +493,9 @@ CheckpointerMain(void)
CheckArchiveTimeout();
/*
- * Send off activity statistics to the stats collector. (The reason
- * why we re-use bgwriter-related code for this is that the bgwriter
- * and checkpointer used to be just one process. It's probably not
- * worth the trouble to split the stats support into two independent
- * stats message types.)
+ * Send off activity statistics to the stats collector.
*/
- pgstat_send_bgwriter();
+ pgstat_send_checkpointer();
/* Send WAL statistics to the stats collector. */
pgstat_send_wal(true);
@@ -577,9 +573,9 @@ HandleCheckpointerInterrupts(void)
* updates the statistics, increment the checkpoint request and send
* the statistics to the stats collector.
*/
- BgWriterStats.m_requested_checkpoints++;
+ PendingCheckpointerStats.m_requested_checkpoints++;
ShutdownXLOG(0, 0);
- pgstat_send_bgwriter();
+ pgstat_send_checkpointer();
pgstat_send_wal(true);
/* Normal exit from the checkpointer is here */
@@ -719,9 +715,9 @@ CheckpointWriteDelay(int flags, double progress)
CheckArchiveTimeout();
/*
- * Report interim activity statistics to the stats collector.
+ * Report interim activity statistics.
*/
- pgstat_send_bgwriter();
+ pgstat_send_checkpointer();
/*
* This sleep used to be connected to bgwriter_delay, typically 200ms.
@@ -1265,8 +1261,10 @@ AbsorbSyncRequests(void)
LWLockAcquire(CheckpointerCommLock, LW_EXCLUSIVE);
/* Transfer stats counts into pending pgstats message */
- BgWriterStats.m_buf_written_backend += CheckpointerShmem->num_backend_writes;
- BgWriterStats.m_buf_fsync_backend += CheckpointerShmem->num_backend_fsync;
+ PendingCheckpointerStats.m_buf_written_backend
+ += CheckpointerShmem->num_backend_writes;
+ PendingCheckpointerStats.m_buf_fsync_backend
+ += CheckpointerShmem->num_backend_fsync;
CheckpointerShmem->num_backend_writes = 0;
CheckpointerShmem->num_backend_fsync = 0;