summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorHeikki Linnakangas2013-01-23 08:01:04 +0000
committerHeikki Linnakangas2013-01-23 08:19:20 +0000
commit990fe3c4edfdabf4f56aa9a403a11f53006d0dd7 (patch)
treed78c1f10bf61639b6e0569923cab4f6d8fd49918 /src/include
parent861ad67bd9546a8328ea31d0141406db16f4c57c (diff)
Fix more issues with cascading replication and timeline switches.
When a standby server follows the master using WAL archive, and it chooses a new timeline (recovery_target_timeline='latest'), it only fetches the timeline history file for the chosen target timeline, not any other history files that might be missing from pg_xlog. For example, if the current timeline is 2, and we choose 4 as the new recovery target timeline, the history file for timeline 3 is not fetched, even if it's part of this server's history. That's enough for the standby itself - the history file for timeline 4 includes timeline 3 as well - but if a cascading standby server wants to recover to timeline 3, it needs the history file. To fix, when a new recovery target timeline is chosen, try to copy any missing history files from the archive to pg_xlog between the old and new target timeline. A second similar issue was with the WAL files. When a standby recovers from archive, and it reaches a segment that contains a switch to a new timeline, recovery fetches only the WAL file labelled with the new timeline's ID. The file from the new timeline contains a copy of the WAL from the old timeline up to the point where the switch happened, and recovery recovers it from the new file. But in streaming replication, walsender only tries to read it from the old timeline's file. To fix, change walsender to read it from the new file, so that it behaves the same as recovery in that sense, and doesn't try to open the possibly nonexistent file with the old timeline's ID.
Diffstat (limited to 'src/include')
-rw-r--r--src/include/access/timeline.h1
-rw-r--r--src/include/replication/walsender_private.h1
2 files changed, 1 insertions, 1 deletions
diff --git a/src/include/access/timeline.h b/src/include/access/timeline.h
index 7d45fcad8a4..2e5e9a42a38 100644
--- a/src/include/access/timeline.h
+++ b/src/include/access/timeline.h
@@ -35,6 +35,7 @@ extern TimeLineID findNewestTimeLine(TimeLineID startTLI);
extern void writeTimeLineHistory(TimeLineID newTLI, TimeLineID parentTLI,
XLogRecPtr switchpoint, char *reason);
extern void writeTimeLineHistoryFile(TimeLineID tli, char *content, int size);
+extern void restoreTimeLineHistoryFiles(TimeLineID begin, TimeLineID end);
extern bool tliInHistory(TimeLineID tli, List *expectedTLIs);
extern TimeLineID tliOfPointInHistory(XLogRecPtr ptr, List *history);
extern XLogRecPtr tliSwitchPoint(TimeLineID tli, List *history,
diff --git a/src/include/replication/walsender_private.h b/src/include/replication/walsender_private.h
index 8f479fda7e5..7eaa21b9f7e 100644
--- a/src/include/replication/walsender_private.h
+++ b/src/include/replication/walsender_private.h
@@ -95,7 +95,6 @@ extern WalSndCtlData *WalSndCtl;
extern void WalSndSetState(WalSndState state);
-extern void XLogRead(char *buf, TimeLineID tli, XLogRecPtr startptr, Size count);
/*
* Internal functions for parsing the replication grammar, in repl_gram.y and