From d464d8e87c7bea818abbc68b83886105f2171e65 Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas Date: Thu, 29 Jan 2009 21:46:43 +0200 Subject: [PATCH] Move the check for whether we've reached a safe starting point *before* checking if we've reached the recovery target. Otherwise, if the first safe starting point is at the exact same record as the recovery target, we'd fail to start up. --- src/backend/access/transam/xlog.c | 52 +++++++++++++++---------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 4b3337797c..87770c16c6 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -5257,6 +5257,32 @@ StartupXLOG(void) } #endif + /* + * Have we reached our safe starting point? If so, we can + * signal postmaster to enter consistent recovery mode. + * + * There are two points in the log we must pass. The first is + * the minRecoveryPoint, which is the LSN at the time the + * base backup was taken that we are about to rollfoward from. + * If recovery has ever crashed or was stopped there is + * another point also: minSafeStartPoint, which is the + * latest LSN that recovery could have reached prior to crash. + */ + if (!reachedSafeStartPoint && + XLByteLE(minSafeStartPoint, EndRecPtr) && + XLByteLE(ControlFile->minRecoveryPoint, EndRecPtr)) + { + reachedSafeStartPoint = true; + if (InArchiveRecovery) + { + ereport(LOG, + (errmsg("consistent recovery state reached at %X/%X", + EndRecPtr.xlogid, EndRecPtr.xrecoff))); + if (IsUnderPostmaster) + SendPostmasterSignal(PMSIGNAL_RECOVERY_START); + } + } + /* * Have we reached our recovery target? */ @@ -5289,32 +5315,6 @@ StartupXLOG(void) LastRec = ReadRecPtr; - /* - * Have we reached our safe starting point? If so, we can - * signal postmaster to enter consistent recovery mode. - * - * There are two points in the log we must pass. The first is - * the minRecoveryPoint, which is the LSN at the time the - * base backup was taken that we are about to rollfoward from. - * If recovery has ever crashed or was stopped there is - * another point also: minSafeStartPoint, which is the - * latest LSN that recovery could have reached prior to crash. - */ - if (!reachedSafeStartPoint && - XLByteLE(minSafeStartPoint, EndRecPtr) && - XLByteLE(ControlFile->minRecoveryPoint, EndRecPtr)) - { - reachedSafeStartPoint = true; - if (InArchiveRecovery) - { - ereport(LOG, - (errmsg("consistent recovery state reached at %X/%X", - EndRecPtr.xlogid, EndRecPtr.xrecoff))); - if (IsUnderPostmaster) - SendPostmasterSignal(PMSIGNAL_RECOVERY_START); - } - } - record = ReadRecord(NULL, LOG); } while (record != NULL && recoveryContinue); -- 2.39.5