diff --git a/doc/src/sgml/high-availability.sgml b/doc/src/sgml/high-availability.sgml
index 1f3d1ea0139..c34f475a3a9 100644
--- a/doc/src/sgml/high-availability.sgml
+++ b/doc/src/sgml/high-availability.sgml
@@ -1383,7 +1383,8 @@ synchronous_standby_names = 'ANY 2 (s1, s2, s3)'
If archive_mode is set to on>, 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 e4beaada12f..75ec9859533 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -733,6 +733,15 @@ WalRcvFetchTimeLineHistoryFiles(TimeLineID first, TimeLineID last)
*/
writeTimeLineHistoryFile(tli, content, len);
+ /*
+ * Mark the streamed history file as ready for archiving
+ * if archive_mode is always.
+ */
+ if (XLogArchiveMode != ARCHIVE_MODE_ALWAYS)
+ XLogArchiveForceDone(fname);
+ else
+ XLogArchiveNotify(fname);
+
pfree(fname);
pfree(content);
}