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
This commit is contained in:
parent
1908abc4a3
commit
7ccefe8610
@ -92,7 +92,7 @@ readTimeLineHistory(TimeLineID targetTLI)
|
|||||||
return list_make1(entry);
|
return list_make1(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (InArchiveRecovery)
|
if (ArchiveRecoveryRequested)
|
||||||
{
|
{
|
||||||
TLHistoryFileName(histfname, targetTLI);
|
TLHistoryFileName(histfname, targetTLI);
|
||||||
fromArchive =
|
fromArchive =
|
||||||
@ -213,7 +213,7 @@ existsTimeLineHistory(TimeLineID probeTLI)
|
|||||||
if (probeTLI == 1)
|
if (probeTLI == 1)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (InArchiveRecovery)
|
if (ArchiveRecoveryRequested)
|
||||||
{
|
{
|
||||||
TLHistoryFileName(histfname, probeTLI);
|
TLHistoryFileName(histfname, probeTLI);
|
||||||
RestoreArchivedFile(path, histfname, "RECOVERYHISTORY", 0, false);
|
RestoreArchivedFile(path, histfname, "RECOVERYHISTORY", 0, false);
|
||||||
@ -316,7 +316,7 @@ writeTimeLineHistory(TimeLineID newTLI, TimeLineID parentTLI,
|
|||||||
/*
|
/*
|
||||||
* If a history file exists for the parent, copy it verbatim
|
* If a history file exists for the parent, copy it verbatim
|
||||||
*/
|
*/
|
||||||
if (InArchiveRecovery)
|
if (ArchiveRecoveryRequested)
|
||||||
{
|
{
|
||||||
TLHistoryFileName(histfname, parentTLI);
|
TLHistoryFileName(histfname, parentTLI);
|
||||||
RestoreArchivedFile(path, histfname, "RECOVERYHISTORY", 0, false);
|
RestoreArchivedFile(path, histfname, "RECOVERYHISTORY", 0, false);
|
||||||
|
@ -200,7 +200,7 @@ static int LocalXLogInsertAllowed = -1;
|
|||||||
* will switch to using offline XLOG archives as soon as we reach the end of
|
* will switch to using offline XLOG archives as soon as we reach the end of
|
||||||
* WAL in pg_xlog.
|
* WAL in pg_xlog.
|
||||||
*/
|
*/
|
||||||
static bool ArchiveRecoveryRequested = false;
|
bool ArchiveRecoveryRequested = false;
|
||||||
bool InArchiveRecovery = false;
|
bool InArchiveRecovery = false;
|
||||||
|
|
||||||
/* Was the last xlog file restored from archive, or local? */
|
/* Was the last xlog file restored from archive, or local? */
|
||||||
@ -4339,11 +4339,6 @@ readRecoveryCommandFile(void)
|
|||||||
*/
|
*/
|
||||||
if (rtliGiven)
|
if (rtliGiven)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
* Temporarily set InArchiveRecovery, so that existsTimeLineHistory
|
|
||||||
* or findNewestTimeLine below will check the archive.
|
|
||||||
*/
|
|
||||||
InArchiveRecovery = true;
|
|
||||||
if (rtli)
|
if (rtli)
|
||||||
{
|
{
|
||||||
/* Timeline 1 does not have a history file, all else should */
|
/* Timeline 1 does not have a history file, all else should */
|
||||||
@ -4360,7 +4355,6 @@ readRecoveryCommandFile(void)
|
|||||||
recoveryTargetTLI = findNewestTimeLine(recoveryTargetTLI);
|
recoveryTargetTLI = findNewestTimeLine(recoveryTargetTLI);
|
||||||
recoveryTargetIsLatest = true;
|
recoveryTargetIsLatest = true;
|
||||||
}
|
}
|
||||||
InArchiveRecovery = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FreeConfigVariables(head);
|
FreeConfigVariables(head);
|
||||||
|
@ -263,6 +263,7 @@ extern void GetOldestRestartPoint(XLogRecPtr *oldrecptr, TimeLineID *oldtli);
|
|||||||
* Exported for the functions in timeline.c and xlogarchive.c. Only valid
|
* Exported for the functions in timeline.c and xlogarchive.c. Only valid
|
||||||
* in the startup process.
|
* in the startup process.
|
||||||
*/
|
*/
|
||||||
|
extern bool ArchiveRecoveryRequested;
|
||||||
extern bool InArchiveRecovery;
|
extern bool InArchiveRecovery;
|
||||||
extern bool StandbyMode;
|
extern bool StandbyMode;
|
||||||
extern char *recoveryRestoreCommand;
|
extern char *recoveryRestoreCommand;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user