From: Fujii Masao <fujii@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: pg_receivewal, pg_basebackup: Fix temporary file cleanup on erro
Date: Wed, 25 Nov 2026 07:23:40 +0000
Message-ID: <E1xW7Lw-00000000EfT-01Ik@gemulon.postgresql.org> (raw)
pg_receivewal, pg_basebackup: Fix temporary file cleanup on errors
pg_receivewal and the WAL streaming process of pg_basebackup could leave
temporary files behind when closing them failed, even though their
removal had been requested. For example, a temporary timeline history
file could remain after a write failure, unnecessarily occupying disk
space.
This happened because dir_close() attempted to unlink a file requested
with CLOSE_UNLINK only if the preceding operations succeeded. Failures
while finalizing compression, writing the final compressed data, or
closing the file could therefore skip the unlink operation.
Fix this by moving the unlink operation into the common cleanup path,
so that it is attempted even after an earlier failure.
Backpatch to all supported versions.
Author: Chao Li <lic@highgo.com>
Reviewed-by: Xuneng Zhou <xunengzhou@gmail.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/9C37FACF-2D67-450D-864A-344F81229860@gmail.com
Backpatch-through: 15
Branch
------
REL_17_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/2a9b6b5d4af701bb0c1ad2fd827bdefb25364782
Modified Files
--------------
src/bin/pg_basebackup/walmethods.c | 27 ++++++++++++++-------------
1 file changed, 14 insertions(+), 13 deletions(-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: fujii@postgresql.org
Subject: Re: pgsql: pg_receivewal, pg_basebackup: Fix temporary file cleanup on erro
In-Reply-To: <E1xW7Lw-00000000EfT-01Ik@gemulon.postgresql.org>
References: <E1xW7Lw-00000000EfT-01Ik@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox