summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFujii Masao <fujii@postgresql.org>2020-09-29 16:21:46 +0900
committerFujii Masao <fujii@postgresql.org>2020-09-29 16:25:20 +0900
commit7be02a3bf03a8bec605d089f34ceb5f441e754a6 (patch)
tree467824ac2f0c7c3ca1038c8ad217cf2162cd8b9b /src
parentacab757ce9ead47a39b4d2d25b91ed2532b8444a (diff)
Archive timeline history files in standby if archive_mode is set to "always".
Previously the standby server didn't archive timeline history files streamed from the primary even when archive_mode is set to "always", while it archives the streamed WAL files. This could cause the PITR to fail because there was no required timeline history file in the archive. The cause of this issue was that walreceiver didn't mark those files as ready for archiving. This commit makes walreceiver mark those streamed timeline history files as ready for archiving if archive_mode=always. Then the archiver process archives the marked timeline history files. Back-patch to all supported versions. Reported-by: Grigory Smolkin Author: Grigory Smolkin, Fujii Masao Reviewed-by: David Zhang, Anastasia Lubennikova Discussion: https://postgr.es/m/54b059d4-2b48-13a4-6f43-95a087c92367@postgrespro.ru
Diffstat (limited to 'src')
-rw-r--r--src/backend/replication/walreceiver.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c
index cf1c363e1c3..5c3a94cc3d9 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -748,6 +748,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);
}