postgres.git / summary / log / commit / refs
commit 65efcf45768c3eb3f91191e8191820da87f72aa6
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 c9c7bbadc9a..58ab42d07d8 100644
--- a/src/bin/pg_basebackup/receivelog.c
+++ b/src/bin/pg_basebackup/receivelog.c
@@ -555,9 +555,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: ed2cc619ac74]