postgres.git / summary / log / commit / refs

commit    ab294dada6d03ca1c3b57ca5469df7e9cbfff8bf
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 f3a2ffb6acf..ec8b3f7e22a 100644 --- a/src/bin/pg_basebackup/receivelog.c +++ b/src/bin/pg_basebackup/receivelog.c @@ -562,9 +562,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: 0e278a7ddee4]