Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit e45057e

Browse files
committed
Don't set reachedMinRecoveryPoint during crash recovery. In crash recovery,
we don't reach consistency before replaying all of the WAL. Rename the variable to reachedConsistency, to make its intention clearer. In master, that was an active bug because of the recent patch to immediately PANIC if a reference to a missing page is found in WAL after reaching consistency, as Tom Lane's test case demonstrated. In 9.1 and 9.0, the only consequence was a misleading "consistent recovery state reached at %X/%X" message in the log at the beginning of crash recovery (the database is not consistent at that point yet). In 8.4, the log message was not printed in crash recovery, even though there was a similar reachedMinRecoveryPoint local variable that was also set early. So, backpatch to 9.1 and 9.0.
1 parent 85d85ff commit e45057e

File tree

1 file changed

+17
-4
lines changed
  • src/backend/access/transam

1 file changed

+17
-4
lines changed

src/backend/access/transam/xlog.c

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,13 @@ static TimeLineID lastPageTLI = 0;
554554
static XLogRecPtr minRecoveryPoint; /* local copy of
555555
* ControlFile->minRecoveryPoint */
556556
static bool updateMinRecoveryPoint = true;
557-
static bool reachedMinRecoveryPoint = false;
557+
558+
/*
559+
* Have we reached a consistent database state? In crash recovery, we have
560+
* to replay all the WAL, so reachedConsistency is never set. During archive
561+
* recovery, the database is consistent once minRecoveryPoint is reached.
562+
*/
563+
static bool reachedConsistency = false;
558564

559565
static bool InRedo = false;
560566

@@ -6952,14 +6958,21 @@ StartupXLOG(void)
69526958
static void
69536959
CheckRecoveryConsistency(void)
69546960
{
6961+
/*
6962+
* During crash recovery, we don't reach a consistent state until we've
6963+
* replayed all the WAL.
6964+
*/
6965+
if (XLogRecPtrIsInvalid(minRecoveryPoint))
6966+
return;
6967+
69556968
/*
69566969
* Have we passed our safe starting point?
69576970
*/
6958-
if (!reachedMinRecoveryPoint &&
6971+
if (!reachedConsistency &&
69596972
XLByteLE(minRecoveryPoint, EndRecPtr) &&
69606973
XLogRecPtrIsInvalid(ControlFile->backupStartPoint))
69616974
{
6962-
reachedMinRecoveryPoint = true;
6975+
reachedConsistency = true;
69636976
ereport(LOG,
69646977
(errmsg("consistent recovery state reached at %X/%X",
69656978
EndRecPtr.xlogid, EndRecPtr.xrecoff)));
@@ -6972,7 +6985,7 @@ CheckRecoveryConsistency(void)
69726985
*/
69736986
if (standbyState == STANDBY_SNAPSHOT_READY &&
69746987
!LocalHotStandbyActive &&
6975-
reachedMinRecoveryPoint &&
6988+
reachedConsistency &&
69766989
IsUnderPostmaster)
69776990
{
69786991
/* use volatile pointer to prevent code rearrangement */

0 commit comments

Comments
 (0)