Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1paJac-0001Bd-MN for pgsql-bugs@arkaria.postgresql.org; Thu, 09 Mar 2023 16:58:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1paJab-0008K9-GX for pgsql-bugs@arkaria.postgresql.org; Thu, 09 Mar 2023 16:58:01 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1paJab-0008K0-7h for pgsql-bugs@lists.postgresql.org; Thu, 09 Mar 2023 16:58:01 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1paJaY-0004Qt-Qs for pgsql-bugs@lists.postgresql.org; Thu, 09 Mar 2023 16:58:00 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 329Gvt0j423732; Thu, 9 Mar 2023 11:57:55 -0500 From: Tom Lane To: exclusion@gmail.com cc: pgsql-bugs@lists.postgresql.org, Etsuro Fujita Subject: Re: BUG #17828: postgres_fdw leaks file descriptors on error and aborts aborted transaction in lack of fds In-reply-to: <17828-122da8cba23236be@postgresql.org> References: <17828-122da8cba23236be@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Thu, 09 Mar 2023 12:00:01 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <423730.1678381075.1@sss.pgh.pa.us> Date: Thu, 09 Mar 2023 11:57:55 -0500 Message-ID: <423731.1678381075@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk PG Bug reporting form writes: > The following script: > [ leaks a file descriptor per error ] Yeah, at least on platforms where WaitEventSets own kernel file descriptors. I don't think it's postgres_fdw's fault though, but that of ExecAppendAsyncEventWait, which is ignoring the possibility of failing partway through. It looks like it'd be sufficient to add a PG_CATCH or PG_FINALLY block there to make sure the WaitEventSet is disposed of properly --- fortunately, it doesn't need to have any longer lifespan than that one function. regards, tom lane