Re: Question: Why Are File Descriptors Not Closed and Accounted for PostgreSQL Backends? - Mailing list pgsql-hackers

From Heikki Linnakangas
Subject Re: Question: Why Are File Descriptors Not Closed and Accounted for PostgreSQL Backends?
Date
Msg-id e340b428-764c-4b44-baea-653769fa454d@iki.fi
Whole thread Raw
In response to Question: Why Are File Descriptors Not Closed and Accounted for PostgreSQL Backends?  (Srinath Reddy Sadipiralla <srinath.reddy@zohocorp.com>)
Responses Re: Question: Why Are File Descriptors Not Closed and Accounted for PostgreSQL Backends?
List pgsql-hackers
On 24/05/2024 15:17, Srinath Reddy Sadipiralla wrote:
> Hi PostgreSQL Community,
> when a backend process starts, pq_init is called where it opens a FD during CreateWaitEventSet()
> 
> 
> if (!AcquireExternalFD())
> {
> /* treat this as though epoll_create1 itself returned EMFILE */
> elog(ERROR, "epoll_create1 failed: %m");
> }
> set->epoll_fd = epoll_create1(EPOLL_CLOEXEC);
> 
> 
> but we didn't closed or called ReleaseExternalFD() for accounting

Yes we do, see FreeWaitEventSet().

The WaitEventSet created fro pq_init() is never explicitly free'd 
though, because it's created in the per-connection backend process. When 
the connection is terminated, the backend process exits, cleaning up any 
resources including the WaitEventSet.

-- 
Heikki Linnakangas
Neon (https://neon.tech)




pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: Add new protocol message to change GUCs for usage with future protocol-only GUCs
Next
From: Robert Haas
Date:
Subject: Re: First draft of PG 17 release notes