postgres.git / summary / log / commit / refs

commit    5dce44589444704a917b2d2f70c99d9ae357da73
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 77a2b4458b3..7781769f960 100644 --- a/src/bin/pg_basebackup/receivelog.c +++ b/src/bin/pg_basebackup/receivelog.c @@ -557,9 +557,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: 8becd1123c98]