Commit d4337a0d authored by Simon Riggs's avatar Simon Riggs

Init crash recovery using the latest available TLI

This simplifies the handling of crashes after fast promotion and various
minor cases that can exist in short timing windows around that case.

Broad fix to bug reported by Michael Paquier on -hackers,
approach prompted by Heikki Linnakangas
parent 1781744c
......@@ -4932,9 +4932,13 @@ StartupXLOG(void)
RelationCacheInitFileRemove();
/*
* Initialize on the assumption we want to recover to the same timeline
* Initialize on the assumption we want to recover to the latest timeline
* that's active according to pg_control.
*/
if (ControlFile->minRecoveryPointTLI >
ControlFile->checkPointCopy.ThisTimeLineID)
recoveryTargetTLI = ControlFile->minRecoveryPointTLI;
else
recoveryTargetTLI = ControlFile->checkPointCopy.ThisTimeLineID;
/*
......@@ -4972,22 +4976,6 @@ StartupXLOG(void)
ereport(LOG,
(errmsg("starting archive recovery")));
}
else if (ControlFile->minRecoveryPointTLI > 0)
{
/*
* If the minRecoveryPointTLI is set when not in Archive Recovery
* it means that we have crashed after ending recovery and
* yet before we wrote a new checkpoint on the new timeline.
* That means we are doing a crash recovery that needs to cross
* timelines to get to our newly assigned timeline again.
* The timeline we are headed for is exact and not 'latest'.
* As soon as we hit a checkpoint, the minRecoveryPointTLI is
* reset, so we will not enter crash recovery again.
*/
Assert(ControlFile->minRecoveryPointTLI != 1);
recoveryTargetTLI = ControlFile->minRecoveryPointTLI;
recoveryTargetIsLatest = false;
}
/*
* Take ownership of the wakeup latch if we're going to sleep during
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment