From 0b6329130e8e4576e97ff763f0e773347e1a88af Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas Date: Thu, 17 Jan 2013 20:23:00 +0200 Subject: Make pg_receivexlog and pg_basebackup -X stream work across timeline switches. This mirrors the changes done earlier to the server in standby mode. When receivelog reaches the end of a timeline, as reported by the server, it fetches the timeline history file of the next timeline, and restarts streaming from the new timeline by issuing a new START_STREAMING command. When pg_receivexlog crosses a timeline, it leaves the .partial suffix on the last segment on the old timeline. This helps you to tell apart a partial segment left in the directory because of a timeline switch, and a completed segment. If you just follow a single server, it won't make a difference, but it can be significant in more complicated scenarios where new WAL is still generated on the old timeline. This includes two small changes to the streaming replication protocol: First, when you reach the end of timeline while streaming, the server now sends the TLI of the next timeline in the server's history to the client. pg_receivexlog uses that as the next timeline, so that it doesn't need to parse the timeline history file like a standby server does. Second, when BASE_BACKUP command sends the begin and end WAL positions, it now also sends the timeline IDs corresponding the positions. --- doc/src/sgml/protocol.sgml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/protocol.sgml b/doc/src/sgml/protocol.sgml index e14627c201e..baae59de6e9 100644 --- a/doc/src/sgml/protocol.sgml +++ b/doc/src/sgml/protocol.sgml @@ -1418,8 +1418,10 @@ The commands accepted in walsender mode are: After streaming all the WAL on a timeline that is not the latest one, the server will end streaming by exiting the COPY mode. When the client - acknowledges this by also exiting COPY mode, the server responds with a - CommandComplete message, and is ready to accept a new command. + acknowledges this by also exiting COPY mode, the server sends a + single-row, single-column result set indicating the next timeline in + this server's history. That is followed by a CommandComplete message, + and the server is ready to accept a new command. @@ -1784,7 +1786,9 @@ The commands accepted in walsender mode are: The first ordinary result set contains the starting position of the - backup, given in XLogRecPtr format as a single column in a single row. + backup, in a single row with two columns. The first column contains + the start position given in XLogRecPtr format, and the second column + contains the corresponding timeline ID. The second ordinary result set has one row for each tablespace. @@ -1827,7 +1831,9 @@ The commands accepted in walsender mode are: ustar interchange format specified in the POSIX 1003.1-2008 standard) dump of the tablespace contents, except that the two trailing blocks of zeroes specified in the standard are omitted. - After the tar data is complete, a final ordinary result set will be sent. + After the tar data is complete, a final ordinary result set will be sent, + containing the WAL end position of the backup, in the same format as + the start position. -- cgit v1.2.3