diff options
-rw-r--r-- | src/backend/access/transam/xlog.c | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index ceb20b79172..7d34218bef0 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -4932,10 +4932,14 @@ 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. */ - recoveryTargetTLI = ControlFile->checkPointCopy.ThisTimeLineID; + if (ControlFile->minRecoveryPointTLI > + ControlFile->checkPointCopy.ThisTimeLineID) + recoveryTargetTLI = ControlFile->minRecoveryPointTLI; + else + recoveryTargetTLI = ControlFile->checkPointCopy.ThisTimeLineID; /* * Check for recovery control file, and if so set up state for offline @@ -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 |