pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
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: <E1xW7Lv-00000000EfN-3xjC@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
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/650925dad03ae3f5048e234d167c9f15df1e9853

Modified Files
--------------
src/bin/pg_basebackup/walmethods.c | 27 ++++++++++++++-------------
1 file changed, 14 insertions(+), 13 deletions(-)



view thread (6+ messages)  latest in thread

Message-ID: <E1xW7Lv-00000000EfN-3xjC@gemulon.postgresql.org>
Permalink:  ../E1xW7Lv-00000000EfN-3xjC@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1xW7Lv-00000000EfN-3xjC@gemulon.postgresql.org

 · 

reply

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: <E1xW7Lv-00000000EfN-3xjC@gemulon.postgresql.org>
  References: <E1xW7Lv-00000000EfN-3xjC@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