mirror of
https://github.com/postgres/postgres.git
synced 2025-11-22 12:22:45 +03:00
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
This commit is contained in:
@@ -460,10 +460,7 @@ CheckpointerMain(char *startup_data, size_t startup_data_len)
|
||||
* Do the checkpoint.
|
||||
*/
|
||||
if (!do_restartpoint)
|
||||
{
|
||||
CreateCheckPoint(flags);
|
||||
ckpt_performed = true;
|
||||
}
|
||||
ckpt_performed = CreateCheckPoint(flags);
|
||||
else
|
||||
ckpt_performed = CreateRestartPoint(flags);
|
||||
|
||||
@@ -484,7 +481,7 @@ CheckpointerMain(char *startup_data, size_t startup_data_len)
|
||||
|
||||
ConditionVariableBroadcast(&CheckpointerShmem->done_cv);
|
||||
|
||||
if (ckpt_performed)
|
||||
if (!do_restartpoint)
|
||||
{
|
||||
/*
|
||||
* Note we record the checkpoint start time not end time as
|
||||
@@ -493,18 +490,32 @@ CheckpointerMain(char *startup_data, size_t startup_data_len)
|
||||
*/
|
||||
last_checkpoint_time = now;
|
||||
|
||||
if (do_restartpoint)
|
||||
PendingCheckpointerStats.restartpoints_performed++;
|
||||
if (ckpt_performed)
|
||||
PendingCheckpointerStats.num_performed++;
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* We were not able to perform the restartpoint (checkpoints
|
||||
* throw an ERROR in case of error). Most likely because we
|
||||
* have not received any new checkpoint WAL records since the
|
||||
* last restartpoint. Try again in 15 s.
|
||||
*/
|
||||
last_checkpoint_time = now - CheckPointTimeout + 15;
|
||||
if (ckpt_performed)
|
||||
{
|
||||
/*
|
||||
* The same as for checkpoint. Please see the
|
||||
* corresponding comment.
|
||||
*/
|
||||
last_checkpoint_time = now;
|
||||
|
||||
PendingCheckpointerStats.restartpoints_performed++;
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* We were not able to perform the restartpoint
|
||||
* (checkpoints throw an ERROR in case of error). Most
|
||||
* likely because we have not received any new checkpoint
|
||||
* WAL records since the last restartpoint. Try again in
|
||||
* 15 s.
|
||||
*/
|
||||
last_checkpoint_time = now - CheckPointTimeout + 15;
|
||||
}
|
||||
}
|
||||
|
||||
ckpt_active = false;
|
||||
|
||||
Reference in New Issue
Block a user