Rely only on checkpoint 1 at end of recovery.
authorSimon Riggs <simon@2ndQuadrant.com>
Thu, 7 Feb 2013 16:33:05 +0000 (16:33 +0000)
committerSimon Riggs <simon@2ndQuadrant.com>
Thu, 7 Feb 2013 16:33:05 +0000 (16:33 +0000)
Searching for checkpoint 2 (previous) is not
correct in all cases.

Bug report from Heikki Linnakangas

src/backend/access/transam/xlog.c

index d644e3982ce7779f701492744cc8e062c0b86c6a..f0df2977a12e62e390c83199b8ba79f3307e6131 100644 (file)
@@ -5777,7 +5777,13 @@ StartupXLOG(void)
                        if (fast_promote)
                        {
                                checkPointLoc = ControlFile->prevCheckPoint;
-                               record = ReadCheckpointRecord(xlogreader, checkPointLoc, 2, false);
+
+                               /*
+                                * Confirm the last checkpoint is available for us to recover
+                                * from if we fail. Note that we don't check for the secondary
+                                * checkpoint since that isn't available in most base backups.
+                                */
+                               record = ReadCheckpointRecord(xlogreader, checkPointLoc, 1, false);
                                if (record != NULL)
                                {
                                        checkpoint_wait = false;