Bug fix for recovery_starts_paused option
authorSimon Riggs <[email protected]>
Tue, 17 Feb 2009 21:44:49 +0000 (21:44 +0000)
committerSimon Riggs <[email protected]>
Tue, 17 Feb 2009 21:44:49 +0000 (21:44 +0000)
src/backend/access/transam/xlog.c

index 079729413f2e3ee005d257eea6fc6740b7988cc5..c48bcae5a5d193eb15e14656755c96ef1475a25c 100644 (file)
@@ -173,6 +173,7 @@ bool InHotStandby = true;
 #define RECOVERY_TARGET_STOP_XID                       7
 #define RECOVERY_TARGET_STOP_TIME                      8
 static int recoveryTargetMode = RECOVERY_TARGET_NONE; 
+static bool recoveryStartsPaused = false;
 
 #define DEFAULT_MAX_STANDBY_DELAY      30
 int maxStandbyDelay = DEFAULT_MAX_STANDBY_DELAY;
@@ -4766,26 +4767,14 @@ readRecoveryCommandFile(void)
                }
                else if (strcmp(tok1, "recovery_starts_paused") == 0)
                {
-                       bool    start_paused;
-
                        /*
                         * enables/disables snapshot processing and user connections
                         */
-                       if (!parse_bool(tok2, &start_paused))
+                       if (!parse_bool(tok2, &recoveryStartsPaused))
                                  ereport(ERROR,
                                                        (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
                                          errmsg("parameter \"recovery_starts_paused\" requires a Boolean value")));
 
-                       if (start_paused)
-                       {
-                               /* use volatile pointer to prevent code rearrangement */
-                               volatile XLogCtlData *xlogctl = XLogCtl;
-
-                               SpinLockAcquire(&xlogctl->info_lck);
-                               xlogctl->recoveryTargetMode = RECOVERY_TARGET_PAUSE_ALL;
-                               SpinLockRelease(&xlogctl->info_lck);                            
-                       }
-
                        ereport(LOG,
                                        (errmsg("recovery_starts_paused = %s", tok2)));
                }
@@ -6003,6 +5992,10 @@ StartupXLOG(void)
                                                {
                                                        InitRecoveryTransactionEnvironment();
                                                        StartCleanupDelayStats();
+       
+                                                       if (recoveryStartsPaused)
+                                                               SetRecoveryTargetMode(RECOVERY_TARGET_PAUSE_ALL, 
+                                                                       InvalidTransactionId, 0, InvalidXLogRecPtr, 0);
                                                }
                                                if (IsUnderPostmaster)
                                                        SendPostmasterSignal(PMSIGNAL_RECOVERY_CONSISTENT);