Hi,
On Tue, Oct 06, 2026 at 07:27:24AM +0900, Michael Paquier wrote:
> 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.
Yeah.
> > 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?
Something like?
"
/*
* Register a memory reset callback to close an open WAL segment.
*
* This is intended for unmanaged file descriptors, such as those returned by
* BasicOpenFile(). It should not be used for descriptors subject to another
* cleanup mechanism, such as those returned by OpenTransientFile(), as those
* may already be closed when this callback runs.
*/
"
Regards,
--
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com