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: Fix resource leaks and error reporting during cle
Date: Fri, 20 Nov 2026 11:31:23 +0000
Message-ID: <E1xUMpu-00000000Vhm-0zAd@gemulon.postgresql.org> (raw)

pg_receivewal: Fix resource leaks and error reporting during cleanup

Failures while finalizing LZ4 compression or writing the final compressed
data could leak a file descriptor and memory. Without --no-loop,
repeated failures across reconnects could accumulate these resources.

This happened because dir_close() returned immediately on these failures,
skipping the code that closes the file and releases its associated
resources. Fix this by closing the file and executing the common cleanup
code before returning.

Backpatch to all supported versions.

Author: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Xuneng Zhou <xunengzhou@gmail.com>
Discussion: https://postgr.es/m/CAHGQGwHfCrEogr6=wr0nCkQevAJ9A3HBqQRjT9iJryO7EjF6Lw@mail.gmail.com
Backpatch-through: 15

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/0cb41ee8070fb0930d2ead13e19304d11d405636

Modified Files
--------------
src/bin/pg_basebackup/receivelog.c | 13 ++++++++++---
src/bin/pg_basebackup/walmethods.c |  9 ++++++---
2 files changed, 16 insertions(+), 6 deletions(-)



view thread (6+ messages)  latest in thread

Message-ID: <E1xUMpu-00000000Vhm-0zAd@gemulon.postgresql.org>
Permalink:  ../E1xUMpu-00000000Vhm-0zAd@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1xUMpu-00000000Vhm-0zAd@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: Fix resource leaks and error reporting during cle
  In-Reply-To: <E1xUMpu-00000000Vhm-0zAd@gemulon.postgresql.org>
  References: <E1xUMpu-00000000Vhm-0zAd@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