Re: Fix resource leaks in pg_receivewal on LZ4 close failures

From: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
To: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Fix resource leaks in pg_receivewal on LZ4 close failures
Date: 2026-11-11 10:51:47
Message-ID: 35C48999-8325-41BC-B327-9552661F39D5@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On Nov 11, 2026, at 17:48, Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote:
>
> Hi,
>
> I'd like to propose the attached patch to fix file descriptor and
> memory leaks when LZ4 compression finalization or the final write
> fails. Without this fix, repeated failures can cause these resources
> to accumulate.
>
> Thoughts?
>
> Regards,
>
> --
> Fujii Masao
> <v1-0001-pg_receivewal-Fix-resource-leaks-and-error-report.patch>

I have a question about the fix in dir_close(). In the current code, r = close(df->fd);, then if r == 0, it will do some operations based on method, such as unlink tmppath. But this patch does:
```
(void) close(df->fd);
goto cleanup;
```

Which bypasses the operations for successful close(df->fd), is that intentional?

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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Ayush Tiwari 2026-11-11 10:56:29 Re: fix special case during recovery for hot_standby=off
Previous Message Fujii Masao 2026-11-11 10:38:25 Re: PL/pgSQL: apply the too_many_rows extra check to EXECUTE ... INTO