log_checkpoints and restartpoint

Started by Fujii Masaoalmost 15 years ago6 messages
#1Fujii Masao
masao.fujii@gmail.com
1 attachment(s)

Hi,

When log_checkpoints is enabled, checkpoint logs the number of
WAL files created/deleted/recycled, but restartpoint doesn't.
This is OK before 9.0 because restartpoint had never created/
deleted/recycled WAL files. But, in 9.0 or later, restartpoint might
do that while walreceiver is running. So I think that it's useful to
log those numbers even in restartpoint in the now.

The attached patch changes LogCheckpointEnd so that it logs
the number of WAL files created/deleted/recycled even in
restartpoint.

And I found the problem about the initialization of CheckpointStats
struct. The attached patch also fixes this.

Comments?

Regards,

--
Fujii Masao
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center

Attachments:

log_restartpoint_v1.patchapplication/octet-stream; name=log_restartpoint_v1.patchDownload
*** a/src/backend/access/transam/xlog.c
--- b/src/backend/access/transam/xlog.c
***************
*** 7051,7060 **** LogCheckpointEnd(bool restartpoint)
--- 7051,7064 ----
  
  	if (restartpoint)
  		elog(LOG, "restartpoint complete: wrote %d buffers (%.1f%%); "
+ 			 "%d transaction log file(s) added, %d removed, %d recycled; "
  			 "write=%ld.%03d s, sync=%ld.%03d s, total=%ld.%03d s; "
  			 "sync files=%d, longest=%ld.%03d s, average=%ld.%03d s",
  			 CheckpointStats.ckpt_bufs_written,
  			 (double) CheckpointStats.ckpt_bufs_written * 100 / NBuffers,
+ 			 CheckpointStats.ckpt_segs_added,
+ 			 CheckpointStats.ckpt_segs_removed,
+ 			 CheckpointStats.ckpt_segs_recycled,
  			 write_secs, write_usecs / 1000,
  			 sync_secs, sync_usecs / 1000,
  			 total_secs, total_usecs / 1000,
***************
*** 7681,7696 **** CreateRestartPoint(int flags)
  	SpinLockRelease(&xlogctl->info_lck);
  	LWLockRelease(WALInsertLock);
  
! 	if (log_checkpoints)
! 	{
! 		/*
! 		 * Prepare to accumulate statistics.
! 		 */
! 		MemSet(&CheckpointStats, 0, sizeof(CheckpointStats));
! 		CheckpointStats.ckpt_start_t = GetCurrentTimestamp();
  
  		LogCheckpointStart(flags, true);
- 	}
  
  	CheckPointGuts(lastCheckPoint.redo, flags);
  
--- 7685,7702 ----
  	SpinLockRelease(&xlogctl->info_lck);
  	LWLockRelease(WALInsertLock);
  
! 	/*
! 	 * Prepare to accumulate statistics.
! 	 *
! 	 * Note: because it is possible for log_checkpoints to change while a
! 	 * checkpoint proceeds, we always accumulate stats, even if
! 	 * log_checkpoints is currently off.
! 	 */
! 	MemSet(&CheckpointStats, 0, sizeof(CheckpointStats));
! 	CheckpointStats.ckpt_start_t = GetCurrentTimestamp();
  
+ 	if (log_checkpoints)
  		LogCheckpointStart(flags, true);
  
  	CheckPointGuts(lastCheckPoint.redo, flags);
  
#2Simon Riggs
simon@2ndQuadrant.com
In reply to: Fujii Masao (#1)
Re: log_checkpoints and restartpoint

On Wed, 2011-01-26 at 13:14 +0900, Fujii Masao wrote:

When log_checkpoints is enabled, checkpoint logs the number of
WAL files created/deleted/recycled, but restartpoint doesn't.
This is OK before 9.0 because restartpoint had never created/
deleted/recycled WAL files. But, in 9.0 or later, restartpoint might
do that while walreceiver is running. So I think that it's useful to
log those numbers even in restartpoint in the now.

The attached patch changes LogCheckpointEnd so that it logs
the number of WAL files created/deleted/recycled even in
restartpoint.

And I found the problem about the initialization of CheckpointStats
struct. The attached patch also fixes this.

Thanks.

Can you add to CF app so we can track this as well? It's easier to track
everything in one place.

--
Simon Riggs http://www.2ndQuadrant.com/books/
PostgreSQL Development, 24x7 Support, Training and Services

#3Fujii Masao
masao.fujii@gmail.com
In reply to: Simon Riggs (#2)
Re: log_checkpoints and restartpoint

On Wed, Jan 26, 2011 at 7:59 PM, Simon Riggs <simon@2ndquadrant.com> wrote:

On Wed, 2011-01-26 at 13:14 +0900, Fujii Masao wrote:

When log_checkpoints is enabled, checkpoint logs the number of
WAL files created/deleted/recycled, but restartpoint doesn't.
This is OK before 9.0 because restartpoint had never created/
deleted/recycled WAL files. But, in 9.0 or later, restartpoint might
do that while walreceiver is running. So I think that it's useful to
log those numbers even in restartpoint in the now.

The attached patch changes LogCheckpointEnd so that it logs
the number of WAL files created/deleted/recycled even in
restartpoint.

And I found the problem about the initialization of CheckpointStats
struct. The attached patch also fixes this.

Thanks.

Can you add to CF app so we can track this as well? It's easier to track
everything in one place.

Sure.

Regards,

--
Fujii Masao
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center

#4Robert Haas
robertmhaas@gmail.com
In reply to: Fujii Masao (#1)
Re: log_checkpoints and restartpoint

On Tue, Jan 25, 2011 at 11:14 PM, Fujii Masao <masao.fujii@gmail.com> wrote:

When log_checkpoints is enabled, checkpoint logs the number of
WAL files created/deleted/recycled, but restartpoint doesn't.
This is OK before 9.0 because restartpoint had never created/
deleted/recycled WAL files. But, in 9.0 or later, restartpoint might
do that while walreceiver is running. So I think that it's useful to
log those numbers even in restartpoint in the now.

The attached patch changes LogCheckpointEnd so that it logs
the number of WAL files created/deleted/recycled even in
restartpoint.

And I found the problem about the initialization of CheckpointStats
struct. The attached patch also fixes this.

This patch looks good to me. For now, I'm marking it Ready for
Committer. Absent objections, I will also commit it.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

#5Itagaki Takahiro
itagaki.takahiro@gmail.com
In reply to: Robert Haas (#4)
Re: log_checkpoints and restartpoint

On Mon, Jan 31, 2011 at 05:17, Robert Haas <robertmhaas@gmail.com> wrote:

The attached patch changes LogCheckpointEnd so that it logs
the number of WAL files created/deleted/recycled even in
restartpoint.

This patch looks good to me.  For now, I'm marking it Ready for
Committer.  Absent objections, I will also commit it.

I don't have any objections for the patch, but we might also need
to add description about restartpoints into log_checkpoints option.

http://developer.postgresql.org/pgdocs/postgres/runtime-config-logging.html#RUNTIME-CONFIG-LOGGING-WHAT

--
Itagaki Takahiro

#6Robert Haas
robertmhaas@gmail.com
In reply to: Itagaki Takahiro (#5)
Re: log_checkpoints and restartpoint

On Wed, Feb 2, 2011 at 8:16 PM, Itagaki Takahiro
<itagaki.takahiro@gmail.com> wrote:

On Mon, Jan 31, 2011 at 05:17, Robert Haas <robertmhaas@gmail.com> wrote:

The attached patch changes LogCheckpointEnd so that it logs
the number of WAL files created/deleted/recycled even in
restartpoint.

This patch looks good to me.  For now, I'm marking it Ready for
Committer.  Absent objections, I will also commit it.

I don't have any objections for the patch, but we might also need
to add description about restartpoints into log_checkpoints option.

http://developer.postgresql.org/pgdocs/postgres/runtime-config-logging.html#RUNTIME-CONFIG-LOGGING-WHAT

Good idea. Committed, with an appropriate (I hope) doc change.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company