On Mon, Oct 5, 2026 at 10:20 AM Bertrand Drouvot <
[email protected]> wrote:
> 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.
>
BasicOpenFile() called repeatedly will accumulate stale descriptors
indefinitely.
int
BasicOpenFile(const char *fileName, int fileFlags)
{
return BasicOpenFilePerm(fileName, fileFlags, pg_file_create_mode);
}
int
BasicOpenFilePerm(const char *fileName, int fileFlags, mode_t fileMode)
{
int fd;
fd = open(fileName, fileFlags & ~PG_O_DIRECT, fileMode);
if (fd >= 0)
{
return fd; /* success! */
While
PathNameOpenFilePerm(const char *fileName, int fileFlags, mode_t fileMode)
Is tracked by a LRU list, and the number of open files in that list is
capped.
I wrote about a potential relation with this before in
https://www.postgresql.org/message-id/CAE8JnxOyYyv6m%3DMz%2BNwQb%3DQj6yFkXD2a%2Bn%3D%2BNes6mhmH6L5PoQ%40mail.gmail.com
Regards,
Alexandre