> The first patch adds a new message that prints the latest completed checkpoint > when the consistent state is reached.
I'm not sure how useful this information is in practice.
Fujii, thanks for reviewing it. It provides the same information as the "last completed transaction was" message.
> It also exposes the checkpoint timestamp > in debug messages.
ereport(DEBUG1, (errmsg("checkpoint record is at %X/%X", (uint32) (checkPointLoc >> 32), (uint32) checkPointLoc))); + ereport(DEBUG1, + (errmsg("checkpoint time is %s", str_time(checkPoint.time))));
The above first debug message displays the LSN of the checkpoint record. OTOH, the second message displays the time when the checkpoint started (not the time when checkpoint record was written at the end of checkpoint). So isn't it confusing to display those inconsistent information together?
Indeed the checkpoint timestamp is from before it determines the REDO LSN. Are you saying the this checkpoint timestamp is inconsistent because it is not near the point it saves the RedoRecPtr? If so, let's move checkPoint.time a few lines below.
/* * Here we update the shared RedoRecPtr for future XLogInsert calls; this * must be done while holding all the insertion locks. * * Note: if we fail to complete the checkpoint, RedoRecPtr will be left * pointing past where it really needs to point. This is okay; the only * consequence is that XLogInsert might back up whole buffers that it * didn't really need to. We can't postpone advancing RedoRecPtr because * XLogInserts that happen while we are dumping buffers must assume that * their buffer changes are not included in the checkpoint. */ RedoRecPtr = XLogCtl->Insert.RedoRecPtr = checkPoint.redo; checkPoint.time = (pg_time_t) time(NULL);
I realized that I was using the wrong variable in one of the debug messages.
> The second patch provides the checkpoint timestamp in the pg_waldump output and > also when you enable wal_debug parameter. The pg_waldump output looks like
You can simplify the code by using timestamptz_to_str() here instead, like xact_desc_commit() does.
I have the same idea until I realized that checkPoint.time is pg_time_t and not TimestampTz. [digging the code a bit...] I figure out there is a function that converts from pg_time_t to TimestampTz: time_t_to_timestamptz(). I removed that ugly code but have to duplicate this function into compat.c. I don't have a strong preference but I'm attaching a new patch.
At the end, I asked myself if it is worth changing this type from pg_time_t to TimestampTz.