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 1jIGoP-000488-1a for pgsql-hackers@arkaria.postgresql.org; Sat, 28 Mar 2020 19:08: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 1jIGoN-0003Cg-LQ for pgsql-hackers@arkaria.postgresql.org; Sat, 28 Mar 2020 19:08: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 1jIGoN-0003CZ-Cm for pgsql-hackers@lists.postgresql.org; Sat, 28 Mar 2020 19:08:03 +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 1jIGoL-0002vQ-F1 for pgsql-hackers@postgresql.org; Sat, 28 Mar 2020 19:08:03 +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 02SJ7td2028907; Sat, 28 Mar 2020 15:07:55 -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: <20200328183904.GI20103@telsasoft.com> References: <27334.1583692669@sss.pgh.pa.us> <20200308191456.GD1357@telsasoft.com> <5679.1583696409@sss.pgh.pa.us> <20200311111921.GQ29065@telsasoft.com> <21724.1583955158@sss.pgh.pa.us> <20200312121156.GB29065@telsasoft.com> <20200316155306.GM26184@telsasoft.com> <3061.1584409130@sss.pgh.pa.us> <20200317020017.GT26184@telsasoft.com> <24244.1585415634@sss.pgh.pa.us> <20200328183904.GI20103@telsasoft.com> Comments: In-reply-to Justin Pryzby message dated "Sat, 28 Mar 2020 13:39:04 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <28905.1585422475.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sat, 28 Mar 2020 15:07:55 -0400 Message-ID: <28906.1585422475@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Justin Pryzby writes: > On Sat, Mar 28, 2020 at 01:13:54PM -0400, Tom Lane wrote: >> so I propose that we fix these directory-scanning functions to silently >> ignore ENOENT failures from stat(). Are there any for which we should = not do >> that? > Maybe we should lstat() the file to determine if it's a dangling link; i= f > lstat() fails, then skip it. Currently, we use stat(), which shows metd= ata of > a link's *target*. Maybe we'd change that. Hm, good point that ENOENT could refer to a symlink's target. Still, I'm not sure it's worth going out of our way to disambiguate that, given that these directories aren't really supposed to contain symlinks. (And on the third hand, if they aren't supposed to, then maybe these functions needn't look through any symlinks? In which case just substituting lstat for stat would resolve the ambiguity.) > Note that I have a patch which generalizes pg_ls_dir_files and makes > pg_ls_dir() a simple wrapper, so if that's pursued, they would behave th= e same > unless I add another flag to do otherwise (but behaving the same has its > merits). It already uses lstat() to show links to dirs as isdir=3Dno, w= hich was > needed to avoid recursing into links-to-dirs in the new helper function > pg_ls_dir_recurse(). https://commitfest.postgresql.org/26/2377/ I think we need a back-patchable fix for the ENOENT failure, seeing that we back-patched the new regression test; intermittent buildfarm failures are no fun in any branch. So new functions aren't too relevant here, although it's fair to look ahead at whether the same behavior will be appropriate for them. regards, tom lane