From b0b9d029176f786aa020badef1fc1e056248d572 Mon Sep 17 00:00:00 2001 From: "Chao Li (Evan)" Date: Wed, 11 Nov 2026 09:35:46 +0800 Subject: [PATCH v1] Check timeline history file write failures in ReceiveXlogStream() writeTimeLineHistoryFile() logs an error and returns false on failure, but its caller ignored the return value and continued streaming. This could let pg_receivewal or pg_basebackup report success despite a failure to save the timeline history file. Check the return value and stop streaming on failure, clearing the query result before returning. Author: Chao Li --- src/bin/pg_basebackup/receivelog.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/bin/pg_basebackup/receivelog.c b/src/bin/pg_basebackup/receivelog.c index 77a2b4458b3..2c51c3a474e 100644 --- a/src/bin/pg_basebackup/receivelog.c +++ b/src/bin/pg_basebackup/receivelog.c @@ -557,9 +557,17 @@ 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 has been written by + * writeTimeLineHistoryFile() + */ + PQclear(res); + return false; + } PQclear(res); } -- 2.50.1 (Apple Git-155)