diff --git a/doc/src/sgml/high-availability.sgml b/doc/src/sgml/high-availability.sgml
index a4e5ed21901..6e893b0efe8 100644
--- a/doc/src/sgml/high-availability.sgml
+++ b/doc/src/sgml/high-availability.sgml
@@ -1248,7 +1248,8 @@ primary_slot_name = 'node_a_slot'
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 7a198910c4a..37ffad6c7b3 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -686,6 +686,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);
}