pg_basebackup: check timeline history file write failures in ReceiveXlogStream()

Started by Chao Li13 days ago5 messageshackers
Jump to latest
#1Chao Li
li.evan.chao@gmail.com

Hi,

While reviewing patch [1]/messages/by-id/f1743511-5fab-482e-94ec-1198ce18723e@riseup.net, I spotted that ReceiveXlogStream() calls writeTimeLineHistoryFile() without checking its result. writeTimeLineHistoryFile() can fail for several reasons and returns false to indicate a failure. This could cause pg_basebackup and pg_receivewal to continue streaming even if the timeline history file was not successfully written.

This seems a very old problem, dating back to 9.3.

Attached is a trivial patch that checks the return value of writeTimeLineHistoryFile() and returns false on failure.

[1]: /messages/by-id/f1743511-5fab-482e-94ec-1198ce18723e@riseup.net

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/

Attachments:

t258447_1
v1-0001-Check-timeline-history-file-write-failures-in-Rec.patchapplication/octet-stream; name=v1-0001-Check-timeline-history-file-write-failures-in-Rec.patch; x-unix-mode=0644Download+11-4
#2Fujii Masao
masao.fujii@gmail.com
In reply to: Chao Li (#1)
Re: pg_basebackup: check timeline history file write failures in ReceiveXlogStream()

On Wed, Nov 11, 2026 at 10:56 AM Chao Li <li.evan.chao@gmail.com> wrote:

Attached is a trivial patch that checks the return value of writeTimeLineHistoryFile() and returns false on failure.

Thanks for the report and patch! LGTM.
Barring any objections, I will commit it.

Regards,

--
Fujii Masao

#3surya poondla
suryapoondla4@gmail.com
In reply to: Fujii Masao (#2)
Re: pg_basebackup: check timeline history file write failures in ReceiveXlogStream()

Hi Chao,

Thank you for reporting the issue and fixing it. The patch looks good to
me.

Regards,
Surya Poondla

#4Fujii Masao
masao.fujii@gmail.com
In reply to: surya poondla (#3)
Re: pg_basebackup: check timeline history file write failures in ReceiveXlogStream()

On Sat, Nov 14, 2026 at 7:21 AM surya poondla <suryapoondla4@gmail.com> wrote:

Thank you for reporting the issue and fixing it. The patch looks good to me.

I've pushed the patch. Thanks!

Regards,

--
Fujii Masao

#5Chao Li
li.evan.chao@gmail.com
In reply to: Fujii Masao (#4)
Re: pg_basebackup: check timeline history file write failures in ReceiveXlogStream()

On Nov 18, 2026, at 12:34, Fujii Masao <masao.fujii@gmail.com> wrote:

On Sat, Nov 14, 2026 at 7:21 AM surya poondla <suryapoondla4@gmail.com> wrote:

Thank you for reporting the issue and fixing it. The patch looks good to me.

I've pushed the patch. Thanks!

Hi Fujii-san, thanks a lot for pushing.

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/