Rename IsRecoveryProcessingMode -> RecoveryInProgress, to avoid confusion
authorHeikki Linnakangas <[email protected]>
Wed, 18 Feb 2009 09:02:10 +0000 (11:02 +0200)
committerHeikki Linnakangas <[email protected]>
Wed, 18 Feb 2009 13:21:58 +0000 (15:21 +0200)
with the actual "processing modes", like BootstrapProcessingMode.

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

index 55763001796c178405ea4861c7c72e82009c5f9f..4ed0b6848ca8fb2642368aa6e75a2982f6ee9262 100644 (file)
@@ -124,11 +124,12 @@ TimeLineID        ThisTimeLineID = 0;
 /*
  * Are we doing recovery from XLOG? 
  *
- * This is only ever true in the startup process, when it's replaying WAL.
- * It's used in functions that need to act differently when called from a
- * redo function (e.g skip WAL logging).  To check whether the system is in
- * recovery regardless of what process you're running in, use
- * IsRecoveryProcessingMode().
+ * This is only ever true in the startup process, even if the system is still
+ * in recovery. Prior to 8.4, all activity during recovery were carried out
+ * by Startup process. This local variable continues to be used in functions
+ * that need to act differently when called from a redo function (e.g skip
+ * WAL logging). To check whether the system is in recovery regardless of what
+ * process you're running in, use RecoveryInProgress().
  */
 bool           InRecovery = false;
 
@@ -136,10 +137,10 @@ bool              InRecovery = false;
 static bool InArchiveRecovery = false;
 
 /*
- * Local copy of shared RecoveryProcessingMode variable. True actually
- * means "not known, need to check the shared state"
+ * Local copy of SharedRecoveryInProgress variable. True actually means "not
+ * known, need to check the shared state"
  */
-static bool LocalRecoveryProcessingMode = true;
+static bool LocalRecoveryInProgress = true;
 
 /* Was the last xlog file restored from archive, or local? */
 static bool restoredFromArchive = false;
@@ -328,10 +329,10 @@ typedef struct XLogCtlData
        TimeLineID      ThisTimeLineID;
 
        /*
-        * SharedRecoveryProcessingMode indicates if we're still in crash or
-        * archive recovery.  It's checked by IsRecoveryProcessingMode().
+        * SharedRecoveryInProgress indicates if we're still in crash or archive
+        * recovery.  It's checked by RecoveryInProgress().
         */
-       bool            SharedRecoveryProcessingMode;
+       bool            SharedRecoveryInProgress;
 
        /*
         * During recovery, we keep a copy of the latest checkpoint record
@@ -531,7 +532,7 @@ XLogInsert(RmgrId rmid, uint8 info, XLogRecData *rdata)
        bool            isLogSwitch = (rmid == RM_XLOG_ID && info == XLOG_SWITCH);
 
        /* cross-check on whether we should be here or not */
-       if (IsRecoveryProcessingMode())
+       if (RecoveryInProgress())
                elog(FATAL, "cannot make new WAL entries during recovery");
 
        /* info's high bits are reserved for use by me */
@@ -1840,7 +1841,7 @@ XLogFlush(XLogRecPtr record)
         * During REDO, we don't try to flush the WAL, but update minRecoveryPoint
         * instead.
         */
-       if (IsRecoveryProcessingMode())
+       if (RecoveryInProgress())
        {
                UpdateMinRecoveryPoint(record, false);
                return;
@@ -1931,7 +1932,7 @@ XLogFlush(XLogRecPtr record)
         * the bad page is encountered again during recovery then we would be
         * unable to restart the database at all!  (This scenario has actually
         * happened in the field several times with 7.1 releases. Note that we
-        * cannot get here while IsRecoveryProcessingMode(), but if the bad page is
+        * cannot get here while RecoveryInProgress(), but if the bad page is
         * brought in and marked dirty during recovery then if a checkpoint were
         * performed at the end of recovery it will try to flush it.
         *
@@ -1971,7 +1972,7 @@ XLogBackgroundFlush(void)
        bool            flexible = true;
 
        /* XLOG doesn't need flushing during recovery */
-       if (IsRecoveryProcessingMode())
+       if (RecoveryInProgress())
                return;
 
        /* read LogwrtResult and update local state */
@@ -2046,7 +2047,7 @@ XLogAsyncCommitFlush(void)
        volatile XLogCtlData *xlogctl = XLogCtl;
 
        /* There's no asynchronously committed transactions during recovery */
-       if (IsRecoveryProcessingMode())
+       if (RecoveryInProgress())
                return;
 
        SpinLockAcquire(&xlogctl->info_lck);
@@ -2066,7 +2067,7 @@ bool
 XLogNeedsFlush(XLogRecPtr record)
 {
        /* XLOG doesn't need flushing during recovery */
-       if (IsRecoveryProcessingMode())
+       if (RecoveryInProgress())
                return false;
 
        /* Quick exit if already known flushed */
@@ -5021,7 +5022,7 @@ StartupXLOG(void)
        uint32          freespace;
        TransactionId oldestActiveXID;
 
-       XLogCtl->SharedRecoveryProcessingMode = true;
+       XLogCtl->SharedRecoveryInProgress = true;
 
        /*
         * Read control file and check XLOG status looks valid.
@@ -5568,7 +5569,7 @@ StartupXLOG(void)
         * Allow writing WAL for us, so that we can create a checkpoint record.
         * But not yet for other backends!
         */
-       LocalRecoveryProcessingMode = false;
+       LocalRecoveryInProgress = false;
 
        if (InRecovery)
        {
@@ -5657,7 +5658,7 @@ StartupXLOG(void)
        /*
         * All done. Allow others to write WAL.
         */
-       XLogCtl->SharedRecoveryProcessingMode = false;
+       XLogCtl->SharedRecoveryInProgress = false;
 }
 
 /*
@@ -5667,30 +5668,30 @@ StartupXLOG(void)
  * variables the first time we see that recovery is finished.
  */
 bool
-IsRecoveryProcessingMode(void)
+RecoveryInProgress(void)
 {
        /*
         * We check shared state each time only until we leave recovery mode.
         * We can't re-enter recovery, so we rely on the local state variable
         * after that.
         */
-       if (!LocalRecoveryProcessingMode)
+       if (!LocalRecoveryInProgress)
                return false;
        else
        {
                /* use volatile pointer to prevent code rearrangement */
                volatile XLogCtlData *xlogctl = XLogCtl;
 
-               LocalRecoveryProcessingMode = xlogctl->SharedRecoveryProcessingMode;
+               LocalRecoveryInProgress = xlogctl->SharedRecoveryInProgress;
 
                /*
                 * Initialize TimeLineID and RedoRecPtr the first time we see that
                 * recovery is finished.
                 */
-               if (!LocalRecoveryProcessingMode)
+               if (!LocalRecoveryInProgress)
                        InitXLOGAccess();
 
-               return LocalRecoveryProcessingMode;
+               return LocalRecoveryInProgress;
        }
 }
 
@@ -5936,7 +5937,7 @@ ShutdownXLOG(int code, Datum arg)
        ereport(LOG,
                        (errmsg("shutting down")));
 
-       if (IsRecoveryProcessingMode())
+       if (RecoveryInProgress())
                CreateRestartPoint(CHECKPOINT_IS_SHUTDOWN | CHECKPOINT_IMMEDIATE);
        else
                CreateCheckPoint(CHECKPOINT_IS_SHUTDOWN | CHECKPOINT_IMMEDIATE);
@@ -6052,7 +6053,7 @@ CreateCheckPoint(int flags)
        int                     nInCommit;
 
        /* shouldn't happen */
-       if (IsRecoveryProcessingMode())
+       if (RecoveryInProgress())
                elog(ERROR, "can't create a checkpoint during recovery");
 
        /*
@@ -6473,7 +6474,7 @@ CreateRestartPoint(int flags)
         * Check that we're still in recovery mode. It's ok if we exit recovery
         * mode after this check, the restart point is valid anyway.
         */
-       if (!IsRecoveryProcessingMode())
+       if (!RecoveryInProgress())
        {
                ereport(DEBUG2,
                                (errmsg("skipping restartpoint, recovery has already ended")));
index e10ec20414de4b2ead2e8949bf93ea624a8d9a05..45d61277bbd74c009e17b10b8f5447568671e8e1 100644 (file)
@@ -432,10 +432,10 @@ BackgroundWriterMain(void)
 
                        /*
                         * Check if we should perform a checkpoint or a restartpoint.
-                        * As a side-effect, IsRecoveryProcessingMode() initializes
+                        * As a side-effect, RecoveryInProgress() initializes
                         * TimeLineID if it's not set yet.
                         */
-                       do_restartpoint = IsRecoveryProcessingMode();
+                       do_restartpoint = RecoveryInProgress();
 
                        /*
                         * Atomically fetch the request flags to figure out what kind of a
@@ -539,7 +539,7 @@ CheckArchiveTimeout(void)
        pg_time_t       now;
        pg_time_t       last_time;
 
-       if (XLogArchiveTimeout <= 0 || IsRecoveryProcessingMode())
+       if (XLogArchiveTimeout <= 0 || RecoveryInProgress())
                return;
 
        now = (pg_time_t) time(NULL);
@@ -618,7 +618,7 @@ BgWriterNap(void)
                (ckpt_active ? ImmediateCheckpointRequested() : checkpoint_requested))
                        break;
                pg_usleep(1000000L);
-               if (!IsRecoveryProcessingMode())
+               if (!RecoveryInProgress())
                        AbsorbFsyncRequests();
                udelay -= 1000000L;
        }
@@ -747,7 +747,7 @@ IsCheckpointOnSchedule(double progress)
         * However, it's good enough for our purposes, we're only calculating an
         * estimate anyway.
         */
-       if (!IsRecoveryProcessingMode())
+       if (!RecoveryInProgress())
        {
                recptr = GetInsertRecPtr();
                elapsed_xlogs =
index d0155bd2de2ed3e1810fb56f6df7007538dba5a9..71a15605611bd28bfc6f487d3339f4fe7e7612a1 100644 (file)
@@ -134,13 +134,6 @@ typedef struct XLogRecData
 
 extern TimeLineID ThisTimeLineID;              /* current TLI */
 
-/* 
- * Prior to 8.4, all activity during recovery were carried out by Startup
- * process. This local variable continues to be used in many parts of the
- * code to indicate actions taken by RecoveryManagers. Other processes who
- * potentially perform work during recovery should check
- * IsRecoveryProcessingMode(), see XLogCtl notes in xlog.c
- */
 extern bool InRecovery;        
                                                                                
 extern XLogRecPtr XactLastRecEnd;
@@ -208,7 +201,7 @@ extern void RestoreBkpBlocks(XLogRecPtr lsn, XLogRecord *record, bool cleanup);
 extern void xlog_redo(XLogRecPtr lsn, XLogRecord *record);
 extern void xlog_desc(StringInfo buf, uint8 xl_info, char *rec);
 
-extern bool IsRecoveryProcessingMode(void);
+extern bool RecoveryInProgress(void);
 
 extern void UpdateControlFile(void);
 extern Size XLOGShmemSize(void);