If a shutdown request comes in while we're still starting up, don't
authorTom Lane <[email protected]>
Sun, 23 Feb 2003 04:48:38 +0000 (04:48 +0000)
committerTom Lane <[email protected]>
Sun, 23 Feb 2003 04:48:38 +0000 (04:48 +0000)
service it until after we execute SetThisStartUpID().  Else shutdown
process will write the wrong SUI into the shutdown checkpoint, which
seems likely to be trouble --- although I've not quite figured out
how significant it really is.

src/backend/postmaster/postmaster.c

index 640a17bbb2f8bbaebd6d3ae32fbcf982941895c8..d2df916063ff7dc944491f7f0db03d1d3034784b 100644 (file)
@@ -1621,7 +1621,26 @@ reaper(SIGNAL_ARGS)
                                ExitPostmaster(1);
                        }
                        StartupPID = 0;
+
+                       /*
+                        * Startup succeeded - remember its ID and RedoRecPtr.
+                        *
+                        * NB: this MUST happen before we fork a checkpoint or shutdown
+                        * subprocess, else they will have wrong local ThisStartUpId.
+                        */
+                       SetThisStartUpID();
+
                        FatalError = false; /* done with recovery */
+
+                       /*
+                        * Arrange for first checkpoint to occur after standard delay.
+                        */
+                       CheckPointPID = 0;
+                       checkpointed = time(NULL);
+
+                       /*
+                        * Go to shutdown mode if a shutdown request was pending.
+                        */
                        if (Shutdown > NoShutdown)
                        {
                                if (ShutdownPID > 0)
@@ -1633,17 +1652,6 @@ reaper(SIGNAL_ARGS)
                                ShutdownPID = ShutdownDataBase();
                        }
 
-                       /*
-                        * Startup succeeded - remember its ID and RedoRecPtr
-                        */
-                       SetThisStartUpID();
-
-                       /*
-                        * Arrange for first checkpoint to occur after standard delay.
-                        */
-                       CheckPointPID = 0;
-                       checkpointed = time(NULL);
-
                        goto reaper_done;
                }