Log restartpoints in the same fashion as checkpoints.
authorRobert Haas <[email protected]>
Thu, 3 Feb 2011 02:08:53 +0000 (21:08 -0500)
committerRobert Haas <[email protected]>
Thu, 3 Feb 2011 02:08:53 +0000 (21:08 -0500)
Prior to 9.0, restartpoints never created, deleted, or recycled WAL
files, but now they can.  This code makes log_checkpoints treat
checkpoints and restartpoints symmetrically.  It also adjusts up
the documentation of the parameter to mention restartpoints.

Fujii Masao.  Docs by me, as suggested by Itagaki Takahiro.

doc/src/sgml/config.sgml
src/backend/access/transam/xlog.c

index 9e08c5addd0a0f9d885084f7c44d27b7fa95852a..68c946245d063468b9071552850a1da4430f6c33 100644 (file)
@@ -3362,10 +3362,9 @@ local0.*    /var/log/postgresql
       </indexterm>
       <listitem>
        <para>
-        Causes checkpoints to be logged in the server log. Some
-        statistics about each checkpoint are included in the log messages,
-        including the number of buffers written and the time spent writing
-        them.
+        Causes checkpoints and restartpoints to be logged in the server log.
+        Some statistics are included in the log messages, including the number
+        of buffers written and the time spent writing them.
         This parameter can only be set in the <filename>postgresql.conf</>
         file or on the server command line. The default is off.
        </para>
index 66cc0049c0614042330bfd431c9de36f8a22e463..25c7e062343d428995d81e02271edf212c7f7e4b 100644 (file)
@@ -7058,10 +7058,14 @@ LogCheckpointEnd(bool restartpoint)
 
    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,
@@ -7688,16 +7692,18 @@ 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();
+   /*
+    * 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);