postgres.git / summary / log / commit / refs
commit f8b67085ddba9121f494f08d82ef4bfc5dc8431c
Author: Fujii Masao <fujii@postgresql.org>
Date: Wed Nov 18 04:25:36 2026 +0000
Stop WAL streaming on timeline history file write failures
pg_basebackup and pg_receivewal could continue streaming WAL after
failing to write a timeline history file, leaving the backup or WAL
archive without a file needed for recovery.
ReceiveXlogStream() ignored the return value of
writeTimeLineHistoryFile(), which reports errors and returns false
on failure. Check the return value and stop the current streaming
attempt if the write fails.
Backpatch to all supported versions.
Author: Chao Li <lic@highgo.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Surya Poondla <suryapoondla4@gmail.com>
Discussion: https://postgr.es/m/530B55ED-C7F7-441C-BBC0-6F3F9901E414@gmail.com
Backpatch-through: 15
src/bin/pg_basebackup/receivelog.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/src/bin/pg_basebackup/receivelog.c b/src/bin/pg_basebackup/receivelog.c
index 354b93ac0ac..087675ccf24 100644
--- a/src/bin/pg_basebackup/receivelog.c
+++ b/src/bin/pg_basebackup/receivelog.c
@@ -556,9 +556,14 @@ ReceiveXlogStream(PGconn *conn, StreamCtl *stream)
}
/* Write the history file to disk */
- writeTimeLineHistoryFile(stream,
- PQgetvalue(res, 0, 0),
- PQgetvalue(res, 0, 1));
+ if (!writeTimeLineHistoryFile(stream,
+ PQgetvalue(res, 0, 0),
+ PQgetvalue(res, 0, 1)))
+ {
+ /* Error message written in writeTimeLineHistoryFile() */
+ PQclear(res);
+ return false;
+ }
PQclear(res);
}
[parent: 573ed87c4cfe]