Re: WAL segment file descriptor leak on read errors can PANIC the server - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: WAL segment file descriptor leak on read errors can PANIC the server
Date
Msg-id asQkTCkor0XLYKnY@paquier.xyz
Whole thread
In response to Re: WAL segment file descriptor leak on read errors can PANIC the server  (Bertrand Drouvot <bertranddrouvot.pg@gmail.com>)
Responses Re: WAL segment file descriptor leak on read errors can PANIC the server
List pgsql-hackers
On Mon, Oct 05, 2026 at 09:20:27AM +0000, Bertrand Drouvot wrote:
> The comment above segment_close() says that ws_file shall be set to a negative
> number, while both this callback and XLogReaderFree() check for -1. I wonder if
> they should test >= 0 instead?

Probably just checking for negative is fine here, yes.

> Worth mentioning that this is intended for descriptors not managed by another
> cleanup mechanism, such as those returned by BasicOpenFile()?  Otherwise, using
> it with OpenTransientFile() could result in segment_close() being called with a
> stale descriptor.

Hmm.  How would you reword this comment?

I am also interested in hearing from Bharath about the latest version
of the patch posted.
--
Michael

Attachment

pgsql-hackers by date:

Previous
From: Masahiko Sawada
Date:
Subject: Re: Fix "unexpected logical decoding status change" error; from concurrent logical decoding activation
Next
From: Michael Paquier
Date:
Subject: Re: pg_resetwal: refuse to run when backup_label exists