8000 Fix tli history file fetching, broken by the archive after crash rece… · danielcode/postgres@51616dc · GitHub
[go: up one dir, main page]

Skip to content

Commit 51616dc

Browse files
committed
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
1 parent d009f90 commit 51616dc

File tree

1 file changed

+2
-8
lines changed
  • src/backend/access/transam

1 file changed

+2
-8
lines changed

src/backend/access/transam/xlog.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4464,7 +4464,7 @@ readTimeLineHistory(TimeLineID targetTLI)
44644464
if (targetTLI == 1)
44654465
return list_make1_int((int) targetTLI);
44664466

4467-
if (InArchiveRecovery)
4467+
if (ArchiveRecoveryRequested)
44684468
{
44694469
TLHistoryFileName(histfname, targetTLI);
44704470
fromArchive =
@@ -4561,7 +4561,7 @@ existsTimeLineHistory(TimeLineID probeTLI)
45614561
if (probeTLI == 1)
45624562
return false;
45634563

4564-
if (InArchiveRecovery)
4564+
if (ArchiveRecoveryRequested)
45654565
{
45664566
TLHistoryFileName(histfname, probeTLI);
45674567
RestoreArchivedFile(path, histfname, "RECOVERYHISTORY", 0);
@@ -5758,11 +5758,6 @@ readRecoveryCommandFile(void)
57585758
*/
57595759
if (rtliGiven)
57605760
{
5761-
/*
5762-
* Temporarily set InArchiveRecovery, so that existsTimeLineHistory
5763-
* or findNewestTimeLine below will check the archive.
5764-
*/
5765-
InArchiveRecovery = true;
57665761
if (rtli)
57675762
{
57685763
/* Timeline 1 does not have a history file, all else should */
@@ -5779,7 +5774,6 @@ readRecoveryCommandFile(void)
57795774
recoveryTargetTLI = findNewestTimeLine(recoveryTargetTLI);
57805775
recoveryTargetIsLatest = true;
57815776
}
5782-
InArchiveRecovery = false;
57835777
}
57845778

57855779
FreeConfigVariables(head);

0 commit comments

Comments
 (0)
0