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

From Bertrand Drouvot
Subject Re: WAL segment file descriptor leak on read errors can PANIC the server
Date
Msg-id asc+WzMJy3gvdchc@bdtpg
Whole thread
In response to Re: WAL segment file descriptor leak on read errors can PANIC the server  (Michael Paquier <michael@paquier.xyz>)
Responses Re: WAL segment file descriptor leak on read errors can PANIC the server
Re: WAL segment file descriptor leak on read errors can PANIC the server
List pgsql-hackers
Hi,

On Thu, Oct 08, 2026 at 12:13:39PM +0900, Michael Paquier wrote:
> On Wed, Oct 07, 2026 at 11:34:40AM -0700, Bharath Rupireddy wrote:
> > I addressed Bertrand's review comments. I renamed the reset callback
> > to keep it generic (closing the open WAL segment file is one cleanup
> > that could be done here but it could be extended for any other
> > resources held by XLogReader). I adjusted the comments. I like the
> > comment around segment_close on not throwing errors, although the core
> > callbacks inherently follow that (they ignore errors from close()),
> > it's good to have it. I ran pgindent and tests. I wrote the commit
> > message.
> 
> Sounds fine to me code-wise.  Applied on HEAD after more review and a
> few tweaks.

Thanks!

As mentioned upthread [1], I think XLogReaderFree() should also check whether
seg.ws_file >= 0.

Please find attached a small patch doing that.

[1]: https://postgr.es/m/asNr203eue0R4zpZ@bdtpg

Regards,

-- 
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com

Attachment

pgsql-hackers by date:

Previous
From: Andrey Borodin
Date:
Subject: Re: Snapshot export on a standby corrupts hint bits on subxact overflow
Next
From: "zengxx"
Date:
Subject: Re: Skip a redundant singleton GROUP BY node