From 32f4de0adfb2037f1402e40b54a5c4043227363f Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas Date: Tue, 4 Dec 2012 15:28:58 +0200 Subject: Write exact xlog position of timeline switch in the timeline history file. This allows us to do some more rigorous sanity checking for various incorrect point-in-time recovery scenarios, and provides more information for debugging purposes. It will also come handy in the upcoming patch to allow timeline switches to be replicated by streaming replication. --- src/include/access/timeline.h | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src/include/access') diff --git a/src/include/access/timeline.h b/src/include/access/timeline.h index f2a7658bc45..785195bd36a 100644 --- a/src/include/access/timeline.h +++ b/src/include/access/timeline.h @@ -14,10 +14,28 @@ #include "access/xlogdefs.h" #include "nodes/pg_list.h" +/* + * A list of these structs describes the timeline history of the server. Each + * TimeLineHistoryEntry represents a piece of WAL belonging to the history, + * from newest to oldest. All WAL positions between 'begin' and 'end' belong to + * the timeline represented by the entry. Together the 'begin' and 'end' + * pointers of all the entries form a contiguous line from beginning of time + * to infinity. + */ +typedef struct +{ + TimeLineID tli; + XLogRecPtr begin; /* inclusive */ + XLogRecPtr end; /* exclusive, 0 means infinity */ +} TimeLineHistoryEntry; + extern List *readTimeLineHistory(TimeLineID targetTLI); extern bool existsTimeLineHistory(TimeLineID probeTLI); extern TimeLineID findNewestTimeLine(TimeLineID startTLI); extern void writeTimeLineHistory(TimeLineID newTLI, TimeLineID parentTLI, - TimeLineID endTLI, XLogSegNo endLogSegNo, char *reason); + XLogRecPtr switchpoint, char *reason); +extern bool tliInHistory(TimeLineID tli, List *expectedTLIs); +extern TimeLineID tliOfPointInHistory(XLogRecPtr ptr, List *history); +extern XLogRecPtr tliSwitchPoint(TimeLineID tli, List *history); #endif /* TIMELINE_H */ -- cgit v1.2.3