Re: Question: Why Are File Descriptors Not Closed and Accounted for PostgreSQL Backends?

From: Srinath Reddy Sadipiralla <srinath(dot)reddy(at)zohocorp(dot)com>
To: "hlinnaka" <hlinnaka(at)iki(dot)fi>
Cc: "pgsql-hackers" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Question: Why Are File Descriptors Not Closed and Accounted for PostgreSQL Backends?
Date: 2024-05-24 14:05:34
Message-ID: 18faaebda89.391037fa8052.3452722946693562480@zohocorp.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Thanks for the reply,yeah i know about FreeWaitEventSet() but that is being used in few places but not for handling backends.

i got it that FDs like FeBeWaitSet->epoll_fd will be free'd when connection is terminated but as i mentioned wouldn't it be an issue if the connection is long living lets take idle which can be running queries for long time,what if we have multiple connections like this running queries using multiple system FDs and reach the limit,cause they are using FDs ,so they may not be free'd.

---- On Fri, 24 May 2024 19:15:54 +0530 Heikki Linnakangas <hlinnaka(at)iki(dot)fi> wrote ---

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)

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2024-05-24 14:17:37 Re: Upgrade Debian CI images to Bookworm
Previous Message Tom Lane 2024-05-24 13:57:36 Re: PG catalog