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 1jB1OC-0004Or-Ks for pgsql-hackers@arkaria.postgresql.org; Sun, 08 Mar 2020 19:15:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jB1OB-0004jS-7G for pgsql-hackers@arkaria.postgresql.org; Sun, 08 Mar 2020 19:15:03 +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 1jB1OA-0004jL-Qz for pgsql-hackers@lists.postgresql.org; Sun, 08 Mar 2020 19:15:02 +0000 Received: from mail-yw1-xc2c.google.com ([2607:f8b0:4864:20::c2c]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jB1O8-00032l-Qc for pgsql-hackers@postgresql.org; Sun, 08 Mar 2020 19:15:02 +0000 Received: by mail-yw1-xc2c.google.com with SMTP id d206so7931299ywa.12 for ; Sun, 08 Mar 2020 12:15:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Nh9TNX3Y91EyniYuFGzLsIry0VYGuOLqo0z8ymeztmU=; b=dnDxntsBY/SSujR8gD6na3cELgfbYLLKWFhSc5HD7CbIlnc4z6pKdn3NS9/arxuHdi mesgzoJrrnDpXZQGJcnrV7ZO7J9E8MDOPMuYRNYzxQml7Js+lJr1nDq7PrImD//mmUx0 APSfiNd6wIzgpz/p9PRux75MkKBzkJYV7Ue8MCzZiK5TXq3scZCqqpw2RKRJ40gERksk +7KCxW2EtWLLUw5RtwYqIgDxsIL3I01t7yg2BCSSo3aw48hzwKL+337hxHeR4Gi/yBSQ kCMzwi3HWvVlcoDclg/l7R9BPTVr6tXPR38q1ppfxjDJNANeZowVdmJ6AvjtOQSFfr/H WJGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Nh9TNX3Y91EyniYuFGzLsIry0VYGuOLqo0z8ymeztmU=; b=HOMtM9hU/kMceiHZhK6Hh2GQfzY5Wdc5KtKshExIWlFx8u2SVkk8ZQimVYEaj9k6W5 nX/3+qhC6TRIMJvitD9UeyVP6gu10ilk3p9GPGuYme2jVP9e9AnfrJ7KKgB8tr8zBKw6 wqlMcIXVY9vF6hfMhBnjMnjPhXWlsiNxS2m2u8buL4uDkUr16HVlhrM8IsmAcdTkDaUg +DkCahDHXl5vMIwczMtoB1hM6BHqsWBmSWTEU5JWEqPg0L4oo0YFdZk8GyRspAua8r9t ThF6PmxIHyyp/jvxKaVidDX9FpTxfSuKkA5dARnMcyRBGJEBTXOC2lGYJBB/7PPMHL0L 9o6g== X-Gm-Message-State: ANhLgQ2Hcm+lMhvMTd+0dWryAbP1fGnAFZ0kPzv+vu3cySqDwzxia409 ti1U2ZbhPJSqqyevcJ7pr1rfTQ== X-Google-Smtp-Source: ADFU+vtX6WJomv7Yr1azIrMHq5s9/oBq79aQqiPoe9TMLegSscbgeYNcB+p7oWHZamiiejoGXUTbhQ== X-Received: by 2002:a25:b904:: with SMTP id x4mr2641158ybj.184.1583694898933; Sun, 08 Mar 2020 12:14:58 -0700 (PDT) Received: from pryzbyj (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id p65sm3793889ywd.5.2020.03.08.12.14.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 08 Mar 2020 12:14:58 -0700 (PDT) Received: by pryzbyj (Postfix, from userid 1000) id A257A8009F4; Sun, 8 Mar 2020 14:14:56 -0500 (CDT) Date: Sun, 8 Mar 2020 14:14:56 -0500 From: Justin Pryzby To: Tom Lane 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 Message-ID: <20200308191456.GD1357@telsasoft.com> References: <20200308173103.GC1357@telsasoft.com> <27334.1583692669@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <27334.1583692669@sss.pgh.pa.us> User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Sun, Mar 08, 2020 at 02:37:49PM -0400, Tom Lane wrote: > Justin Pryzby writes: > > While working on a patch, I noticed this pre-existing behavior, which seems to > > be new since v11, maybe due to changes to SRF. > > > |postgres=# SELECT pg_ls_dir('.') LIMIT 1; > > |WARNING: 1 temporary files and directories not closed at end-of-transaction > > 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. Thanks for the analysis. Do you mean it should enumerate all files during the initial SRF call, or use something other than the SRF_* macros ? -- Justin