mirror of
https://github.com/postgres/postgres.git
synced 2025-06-29 10:41:53 +03:00
Publish checkpoint timing information to pg_stat_bgwriter.
Greg Smith, Peter Geoghegan, and Robert Haas
This commit is contained in:
@ -7511,9 +7511,6 @@ LogCheckpointEnd(bool restartpoint)
|
||||
|
||||
CheckpointStats.ckpt_end_t = GetCurrentTimestamp();
|
||||
|
||||
TimestampDifference(CheckpointStats.ckpt_start_t,
|
||||
CheckpointStats.ckpt_end_t,
|
||||
&total_secs, &total_usecs);
|
||||
|
||||
TimestampDifference(CheckpointStats.ckpt_write_t,
|
||||
CheckpointStats.ckpt_sync_t,
|
||||
@ -7523,6 +7520,23 @@ LogCheckpointEnd(bool restartpoint)
|
||||
CheckpointStats.ckpt_sync_end_t,
|
||||
&sync_secs, &sync_usecs);
|
||||
|
||||
/* Record checkpoint timing summary data. */
|
||||
BgWriterStats.m_checkpoint_write_time +=
|
||||
write_secs * 1000 + write_usecs / 1000;
|
||||
BgWriterStats.m_checkpoint_sync_time +=
|
||||
sync_secs * 1000 + sync_usecs / 1000;
|
||||
|
||||
/*
|
||||
* All of the published timing statistics are accounted for. Only
|
||||
* continue if a log message is to be written.
|
||||
*/
|
||||
if (!log_checkpoints)
|
||||
return;
|
||||
|
||||
TimestampDifference(CheckpointStats.ckpt_start_t,
|
||||
CheckpointStats.ckpt_end_t,
|
||||
&total_secs, &total_usecs);
|
||||
|
||||
/*
|
||||
* Timing values returned from CheckpointStats are in microseconds.
|
||||
* Convert to the second plus microsecond form that TimestampDifference
|
||||
@ -7971,9 +7985,8 @@ CreateCheckPoint(int flags)
|
||||
if (!RecoveryInProgress())
|
||||
TruncateSUBTRANS(GetOldestXmin(true, false));
|
||||
|
||||
/* All real work is done, but log before releasing lock. */
|
||||
if (log_checkpoints)
|
||||
LogCheckpointEnd(false);
|
||||
/* Real work is done, but log and update stats before releasing lock. */
|
||||
LogCheckpointEnd(false);
|
||||
|
||||
TRACE_POSTGRESQL_CHECKPOINT_DONE(CheckpointStats.ckpt_bufs_written,
|
||||
NBuffers,
|
||||
@ -8237,9 +8250,8 @@ CreateRestartPoint(int flags)
|
||||
if (EnableHotStandby)
|
||||
TruncateSUBTRANS(GetOldestXmin(true, false));
|
||||
|
||||
/* All real work is done, but log before releasing lock. */
|
||||
if (log_checkpoints)
|
||||
LogCheckpointEnd(true);
|
||||
/* Real work is done, but log and update before releasing lock. */
|
||||
LogCheckpointEnd(true);
|
||||
|
||||
xtime = GetLatestXTime();
|
||||
ereport((log_checkpoints ? LOG : DEBUG2),
|
||||
|
Reference in New Issue
Block a user