v17-0002-send-stats-for-checkpointer-when-shutdown.patch
text/x-diff
Filename: v17-0002-send-stats-for-checkpointer-when-shutdown.patch
Type: text/x-diff
Part: 1
Patch
Format: unified
Series: patch v17-0002
| File | + | − |
|---|---|---|
| src/backend/postmaster/checkpointer.c | 33 | 12 |
diff --git a/src/backend/postmaster/checkpointer.c b/src/backend/postmaster/checkpointer.c
index 3894f4a270..20454d4040 100644
--- a/src/backend/postmaster/checkpointer.c
+++ b/src/backend/postmaster/checkpointer.c
@@ -168,6 +168,7 @@ static bool IsCheckpointOnSchedule(double progress);
static bool ImmediateCheckpointRequested(void);
static bool CompactCheckpointerRequestQueue(void);
static void UpdateSharedMemoryConfig(void);
+static void pgstat_send_checkpointer(void);
/* Signal handlers */
static void ReqCheckpointHandler(SIGNAL_ARGS);
@@ -495,17 +496,8 @@ CheckpointerMain(void)
/* Check for archive_timeout and switch xlog files if necessary. */
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.)
- */
- pgstat_send_bgwriter();
-
- /* Send WAL statistics to the stats collector. */
- pgstat_report_wal();
+ /* Send the statistics for the checkpointer to the stats collector */
+ pgstat_send_checkpointer();
/*
* If any checkpoint flags have been set, redo the loop to handle the
@@ -572,8 +564,18 @@ HandleCheckpointerInterrupts(void)
* back to the sigsetjmp block above
*/
ExitOnAnyError = true;
- /* Close down the database */
+
+ /*
+ * Close down the database.
+ *
+ * Since ShutdownXLOG() creates restartpoint or checkpoint and updates
+ * the statistics, increment the checkpoint request and send the
+ * statistics to the stats collector.
+ */
+ BgWriterStats.m_requested_checkpoints++;
ShutdownXLOG(0, 0);
+ pgstat_send_checkpointer();
+
/* Normal exit from the checkpointer is here */
proc_exit(0); /* done */
}
@@ -1335,3 +1337,22 @@ FirstCallSinceLastCheckpoint(void)
return FirstCall;
}
+
+/*
+ * Send the statistics for the checkpointer to the stats collector
+ */
+static void
+pgstat_send_checkpointer(void)
+{
+ /*
+ * 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.)
+ */
+ pgstat_send_bgwriter();
+
+ /* Send WAL statistics to the stats collector. */
+ pgstat_report_wal();
+}