Remove the signaling to request hurrying a restartpoint. I don't see any
authorHeikki Linnakangas <heikki@enterprisedb.com>
Wed, 28 Jan 2009 08:50:53 +0000 (10:50 +0200)
committerHeikki Linnakangas <heikki@enterprisedb.com>
Wed, 28 Jan 2009 08:50:53 +0000 (10:50 +0200)
reason for that. Instead, make sure that the bgwriter processes a checkpoint
request as such, and not as a restartoint request, if we've just ended
recovery.

src/backend/access/transam/xlog.c
src/backend/postmaster/bgwriter.c
src/include/postmaster/bgwriter.h

index 226e96953d2fccfdae744d4824fb35aabb2448bd..8c3083ae544f8d5dc01def60a9b70e168b1e92ee 100644 (file)
@@ -6475,26 +6475,6 @@ exitRecovery(void)
        rdata.len = sizeof(TimeLineID);
        rdata.next = NULL;
 
-       /*
-        * If a restartpoint is in progress, we will not be able to successfully
-        * acquire CheckpointLock. If bgwriter is still in progress then send
-        * a second signal to nudge bgwriter to go faster so we can avoid delay.
-        * Then wait for lock, so we know the restartpoint has completed. We do
-        * this because we don't want to interrupt the restartpoint half way
-        * through, which might leave us in a mess and we want to be robust. We're
-        * going to checkpoint soon anyway, so not it's not wasted effort.
-        */
-       if (LWLockConditionalAcquire(CheckpointLock, LW_EXCLUSIVE))
-               LWLockRelease(CheckpointLock);
-       else
-       {
-               RequestRestartPointCompletion();
-               ereport(LOG,
-                       (errmsg("startup process waiting for restartpoint to complete")));
-               LWLockAcquire(CheckpointLock, LW_EXCLUSIVE);
-               LWLockRelease(CheckpointLock);
-       }       
-
        /*
         * This is the only type of WAL message that can be inserted during
         * recovery. This ensures that we don't allow others to get access
index f9ab290823a5cc0cb6d3120de676dd3aa90d0159..428a440b03914431c0e54e823919356d20aed26c 100644 (file)
@@ -426,13 +426,6 @@ BackgroundWriterMain(void)
                        /* Normal exit from the bgwriter is here */
                        proc_exit(0);           /* done */
                }
-               if (BgWriterRecoveryMode && !IsRecoveryProcessingMode())
-               {
-                       elog(DEBUG1, "bgwriter changing from recovery to normal mode");
-                       InitXLOGAccess();
-                       BgWriterRecoveryMode = false;
-               }
 
                /*
                 * Force a checkpoint if too much time has elapsed since the last one.
@@ -450,6 +443,21 @@ BackgroundWriterMain(void)
                        flags |= CHECKPOINT_CAUSE_TIME;
                }
 
+               /*
+                * Check if we've exited recovery. We do this after determining
+                * whether to perform a checkpoint or not, to be sure that we
+                * perform a real checkpoint and not a restartpoint, if someone
+                * (like the startup process!) requested a checkpoint immediately
+                * after exiting recovery.
+                */
+               if (BgWriterRecoveryMode && !IsRecoveryProcessingMode())
+               {
+                       elog(DEBUG1, "bgwriter changing from recovery to normal mode");
+                       InitXLOGAccess();
+                       BgWriterRecoveryMode = false;
+               }
+
                /*
                 * Do a checkpoint if requested, otherwise do one cycle of
                 * dirty-buffer writing.
@@ -1040,19 +1048,6 @@ RequestCheckpoint(int flags)
        }
 }
 
-/* 
- * Sends another checkpoint request signal to bgwriter, which causes it
- * to avoid smoothed writes and continue processing as if it had been
- * called with CHECKPOINT_IMMEDIATE. This is used at the end of recovery.
- */
-void
-RequestRestartPointCompletion(void)
-{
-       if (BgWriterShmem->bgwriter_pid != 0 &&
-               kill(BgWriterShmem->bgwriter_pid, SIGINT) != 0)
-               elog(LOG, "could not signal for restartpoint immediate: %m");
-}
-
 /*
  * ForwardFsyncRequest
  *             Forward a file-fsync request from a backend to the bgwriter
index 35f24d68c2f0218740d6ea2d7b09773cd1e9f6cc..d52d12ce2100ca6a6544651083bf738ea6502b1b 100644 (file)
@@ -26,7 +26,6 @@ extern double CheckPointCompletionTarget;
 extern void BackgroundWriterMain(void);
 
 extern void RequestCheckpoint(int flags);
-extern void RequestRestartPointCompletion(void);
 
 extern void CheckpointWriteDelay(int flags, double progress);