From: Heikki Linnakangas Date: Thu, 7 Mar 2013 10:18:41 +0000 (+0200) Subject: Fix tli history file fetching, broken by the archive after crash recevery patch. X-Git-Tag: REL9_2_4~24 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=51616dcda47a416ef3169dc3d1f3ca199d7a4a5d;p=postgresql Fix tli history file fetching, broken by the archive after crash recevery patch. If we were about to enter archive recovery after crash recovery, we scanned the archive for the latest tli history file, and set the recovery target timeline to that. However, when we actually tried to read the history file, we would not fetch the file from the archive, because we were not in archive recovery yet. To fix, make readTimeLineHistory and existsTimeLineHistory to always fetch the file from archive if archive recovery is requested, even if we're not in archive recovery yet. Backpatch to 9.2. Mitsumasa KONDO --- diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 0666a883ea..a4bc8c88eb 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -4464,7 +4464,7 @@ readTimeLineHistory(TimeLineID targetTLI) if (targetTLI == 1) return list_make1_int((int) targetTLI); - if (InArchiveRecovery) + if (ArchiveRecoveryRequested) { TLHistoryFileName(histfname, targetTLI); fromArchive = @@ -4561,7 +4561,7 @@ existsTimeLineHistory(TimeLineID probeTLI) if (probeTLI == 1) return false; - if (InArchiveRecovery) + if (ArchiveRecoveryRequested) { TLHistoryFileName(histfname, probeTLI); RestoreArchivedFile(path, histfname, "RECOVERYHISTORY", 0); @@ -5758,11 +5758,6 @@ readRecoveryCommandFile(void) */ if (rtliGiven) { - /* - * Temporarily set InArchiveRecovery, so that existsTimeLineHistory - * or findNewestTimeLine below will check the archive. - */ - InArchiveRecovery = true; if (rtli) { /* Timeline 1 does not have a history file, all else should */ @@ -5779,7 +5774,6 @@ readRecoveryCommandFile(void) recoveryTargetTLI = findNewestTimeLine(recoveryTargetTLI); recoveryTargetIsLatest = true; } - InArchiveRecovery = false; } FreeConfigVariables(head);