Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1jB0oX-0000RW-Km for pgsql-hackers@arkaria.postgresql.org; Sun, 08 Mar 2020 18:38:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jB0oW-00017D-FL for pgsql-hackers@arkaria.postgresql.org; Sun, 08 Mar 2020 18:38:12 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1jB0oW-00015Q-6W for pgsql-hackers@lists.postgresql.org; Sun, 08 Mar 2020 18:38:12 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jB0oP-0002mN-Sf for pgsql-hackers@postgresql.org; Sun, 08 Mar 2020 18:38:11 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id 028IbnBS027335; Sun, 8 Mar 2020 14:37:49 -0400 From: Tom Lane To: Justin Pryzby cc: pgsql-hackers@postgresql.org, Fabien COELHO , Alvaro Herrera , David Steele , "Bossart, Nathan" , Thomas Munro Subject: Re: pg11+: pg_ls_*dir LIMIT 1: temporary files .. not closed at end-of-transaction In-reply-to: <20200308173103.GC1357@telsasoft.com> References: <20200308173103.GC1357@telsasoft.com> Comments: In-reply-to Justin Pryzby message dated "Sun, 08 Mar 2020 12:31:03 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <27333.1583692669.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sun, 08 Mar 2020 14:37:49 -0400 Message-ID: <27334.1583692669@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Justin Pryzby writes: > While working on a patch, I noticed this pre-existing behavior, which se= ems to > be new since v11, maybe due to changes to SRF. > |postgres=3D# SELECT pg_ls_dir('.') LIMIT 1; > |WARNING: 1 temporary files and directories not closed at end-of-transa= ction Hmm, actually it looks to me like pg_ls_dir has been broken forever. The reason the warning didn't show up before v11 is that CleanupTempFiles didn't bleat about leaked "allocated" directories before that (cf 9cb7db3f0). I guess we ought to change that function to use returns-a-tuplestore protocol instead of thinking it can hold a directory open across calls. It's not hard to think of use-cases where the existing behavior would cause issues worse than a nanny-ish WARNING, especially on platforms with tight "ulimit -n" limits. regards, tom lane