Skip to content

Commit b82640d

Browse files
committed
Send statistics collected during shutdown checkpoint to the stats collector.
When shutdown is requested, checkpointer performs checkpoint or restartpoint, and updates the statistics, before it exits. But previously checkpointer didn't send those statistics to the stats collector. Shutdown checkpoint and restartpoint are treated as requested ones instead of scheduled ones, so the number of them are counted in pg_stat_bgwriter.checkpoints_req column. Author: Masahiro Ikeda Reviewed-by: Fujii Masao Discussion: https://postgr.es/m/0509ad67b585a5b86a83d445dfa75392@oss.nttdata.com
1 parent 33394ee commit b82640d

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/backend/postmaster/checkpointer.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,8 +572,19 @@ HandleCheckpointerInterrupts(void)
572572
* back to the sigsetjmp block above
573573
*/
574574
ExitOnAnyError = true;
575-
/* Close down the database */
575+
576+
/*
577+
* Close down the database.
578+
*
579+
* Since ShutdownXLOG() creates restartpoint or checkpoint, and
580+
* updates the statistics, increment the checkpoint request and send
581+
* the statistics to the stats collector.
582+
*/
583+
BgWriterStats.m_requested_checkpoints++;
576584
ShutdownXLOG(0, 0);
585+
pgstat_send_bgwriter();
586+
pgstat_report_wal();
587+
577588
/* Normal exit from the checkpointer is here */
578589
proc_exit(0); /* done */
579590
}

0 commit comments

Comments
 (0)