Re: WAL segment file descriptor leak on read errors can PANIC the server

From: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, Sami Imseih <samimseih(dot)pg(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: WAL segment file descriptor leak on read errors can PANIC the server
Date: 2026-10-08 06:55:23
Message-ID: asc+WzMJy3gvdchc@bdtpg
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: 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 Content-Type Size
v1-0001-xlogreader-Treat-any-negative-segment-descriptor-.patch text/x-diff 1.3 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Previous Message Andrey Borodin 2026-10-08 06:27:01 Re: Snapshot export on a standby corrupts hint bits on subxact overflow