diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 0666a883eafc53c4a00c4d4778d68ee9d44730d0..a4bc8c88eb69da0824461a9a22f4558a6f9780bf 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);