From d194d7a52630d855f43edbf0129e131099af6c14 Mon Sep 17 00:00:00 2001
From: Heikki Linnakangas <heikki.linnakangas@iki.fi>
Date: Wed, 2 Jan 2013 14:35:15 +0200
Subject: [PATCH] Fix bug in streaming replication over multiple tli switches.

After receiving some WAL over streaming replication, try to open the file
from the timeline we're currently recieving, not recoveryTargetTLI. They
are usually the same, which is why wasn't noticed before, but you'd get
an error if there have been more than one timeline switch between the
current point in WAL and the recovery target.
---
 src/backend/access/transam/xlog.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index b43412d605a..c847913183c 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -9745,7 +9745,7 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
 					if (readFile < 0)
 					{
 						readFile = XLogFileRead(readSegNo, PANIC,
-												recoveryTargetTLI,
+												receiveTLI,
 												XLOG_FROM_STREAM, false);
 						Assert(readFile >= 0);
 					}
-- 
GitLab