postgres.git / summary / log / commit / refs

commit    d758df2389af8c8b8deff22db1b977e6040deb37
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 77894b721e1..66f0b8251d2 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: 21c45d45d04e]