history_replica_v3.patch

text/plain

Filename: history_replica_v3.patch
Type: text/plain
Part: 0
Message: Re: history file on replica and double switchover

Patch

Format: unified
Series: patch v3
File+
doc/src/sgml/high-availability.sgml 2 1
src/backend/replication/walreceiver.c 4 0
diff --git a/doc/src/sgml/high-availability.sgml b/doc/src/sgml/high-availability.sgml
index beb309e668..42f01c515f 100644
--- a/doc/src/sgml/high-availability.sgml
+++ b/doc/src/sgml/high-availability.sgml
@@ -1395,7 +1395,8 @@ synchronous_standby_names = 'ANY 2 (s1, s2, s3)'
      If <varname>archive_mode</varname> is set to <literal>on</literal>, the
      archiver is not enabled during recovery or standby mode. If the standby
      server is promoted, it will start archiving after the promotion, but
-     will not archive any WAL it did not generate itself. To get a complete
+     will not archive any WAL or timeline history files that
+     it did not generate itself. To get a complete
      series of WAL files in the archive, you must ensure that all WAL is
      archived, before it reaches the standby. This is inherently true with
      file-based log shipping, as the standby can only restore files that
diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c
index 17f1a49f87..32693c56db 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -758,6 +758,10 @@ WalRcvFetchTimeLineHistoryFiles(TimeLineID first, TimeLineID last)
 			 */
 			writeTimeLineHistoryFile(tli, content, len);
 
+			/* Mark history file as ready for archiving */
+			if (XLogArchiveMode == ARCHIVE_MODE_ALWAYS)
+				XLogArchiveNotify(fname);
+
 			pfree(fname);
 			pfree(content);
 		}