Skip to content

Commit 62c46ee

Browse files
committed
Add checkpoint and REDO LSN to log_checkpoints message.
It is useful for debugging purposes to report the checkpoint LSN and REDO LSN in log_checkpoints message. It can give more context while analyzing checkpoint-related issues. pg_controldata reports the last checkpoint LSN and REDO LSN, but having this information alongside the log message helps analyze issues that happened previously, connect the dots and identify the root cause. Author: Bharath Rupireddy, Kyotaro Horiguchi Reviewed-by: Michael Paquier, Julien Rouhaud, Nathan Bossart, Fujii Masao, Greg Stark Discussion: https://postgr.es/m/CALj2ACWt6kqriAHrO+AJj+OmP=suwbktHT5JoYAn-nqZe2gd2g@mail.gmail.com
1 parent 8d367a4 commit 62c46ee

File tree

1 file changed

+15
-4
lines changed
  • src/backend/access/transam

1 file changed

+15
-4
lines changed

src/backend/access/transam/xlog.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6129,13 +6129,19 @@ LogCheckpointEnd(bool restartpoint)
61296129
CheckpointStats.ckpt_sync_rels;
61306130
average_msecs = (long) ((average_sync_time + 999) / 1000);
61316131

6132+
/*
6133+
* ControlFileLock is not required to see ControlFile->checkPoint and
6134+
* ->checkPointCopy here as we are the only updator of those variables at
6135+
* this moment.
6136+
*/
61326137
if (restartpoint)
61336138
ereport(LOG,
61346139
(errmsg("restartpoint complete: wrote %d buffers (%.1f%%); "
61356140
"%d WAL file(s) added, %d removed, %d recycled; "
61366141
"write=%ld.%03d s, sync=%ld.%03d s, total=%ld.%03d s; "
61376142
"sync files=%d, longest=%ld.%03d s, average=%ld.%03d s; "
6138-
"distance=%d kB, estimate=%d kB",
6143+
"distance=%d kB, estimate=%d kB; "
6144+
"lsn=%X/%X, redo lsn=%X/%X",
61396145
CheckpointStats.ckpt_bufs_written,
61406146
(double) CheckpointStats.ckpt_bufs_written * 100 / NBuffers,
61416147
CheckpointStats.ckpt_segs_added,
@@ -6148,14 +6154,17 @@ LogCheckpointEnd(bool restartpoint)
61486154
longest_msecs / 1000, (int) (longest_msecs % 1000),
61496155
average_msecs / 1000, (int) (average_msecs % 1000),
61506156
(int) (PrevCheckPointDistance / 1024.0),
6151-
(int) (CheckPointDistanceEstimate / 1024.0))));
6157+
(int) (CheckPointDistanceEstimate / 1024.0),
6158+
LSN_FORMAT_ARGS(ControlFile->checkPoint),
6159+
LSN_FORMAT_ARGS(ControlFile->checkPointCopy.redo))));
61526160
else
61536161
ereport(LOG,
61546162
(errmsg("checkpoint complete: wrote %d buffers (%.1f%%); "
61556163
"%d WAL file(s) added, %d removed, %d recycled; "
61566164
"write=%ld.%03d s, sync=%ld.%03d s, total=%ld.%03d s; "
61576165
"sync files=%d, longest=%ld.%03d s, average=%ld.%03d s; "
6158-
"distance=%d kB, estimate=%d kB",
6166+
"distance=%d kB, estimate=%d kB; "
6167+
"lsn=%X/%X, redo lsn=%X/%X",
61596168
CheckpointStats.ckpt_bufs_written,
61606169
(double) CheckpointStats.ckpt_bufs_written * 100 / NBuffers,
61616170
CheckpointStats.ckpt_segs_added,
@@ -6168,7 +6177,9 @@ LogCheckpointEnd(bool restartpoint)
61686177
longest_msecs / 1000, (int) (longest_msecs % 1000),
61696178
average_msecs / 1000, (int) (average_msecs % 1000),
61706179
(int) (PrevCheckPointDistance / 1024.0),
6171-
(int) (CheckPointDistanceEstimate / 1024.0))));
6180+
(int) (CheckPointDistanceEstimate / 1024.0),
6181+
LSN_FORMAT_ARGS(ControlFile->checkPoint),
6182+
LSN_FORMAT_ARGS(ControlFile->checkPointCopy.redo))));
61726183
}
61736184

61746185
/*

0 commit comments

Comments
 (0)