Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jIeIh-0000ZU-VZ for pgsql-hackers@arkaria.postgresql.org; Sun, 29 Mar 2020 20:12:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jIeI9-00056a-Tb for pgsql-hackers@arkaria.postgresql.org; Sun, 29 Mar 2020 20:12:21 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jIeI9-00056S-Jg for pgsql-hackers@lists.postgresql.org; Sun, 29 Mar 2020 20:12:21 +0000 Received: from mail-qk1-x744.google.com ([2607:f8b0:4864:20::744]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jIeI6-0005e5-Ou for pgsql-hackers@postgresql.org; Sun, 29 Mar 2020 20:12:20 +0000 Received: by mail-qk1-x744.google.com with SMTP id b62so16930343qkf.6 for ; Sun, 29 Mar 2020 13:12:18 -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=t7NnMGwlWRDhlz/PioKMfrgEqxt5G8CiT2zntcHxSO0=; b=Ndc1e8LMpOqb0FaIUyCBEp2vwBSn52PqyMKu6/ZLnUQ7goNacy4cyg5oV2e7OCP3ob +NL72L44fNjAHMGJ024KwvUvFMkidbP9TisXa4aPw39qqe78Z7j63GWcvHPIJPIiW/Eh yWUfKTKX2QxP0hdCwldE4bX7lkT5hsESX8/hH7iZ12Ud6bys/JAsJF3r7/iNLBDhta+e pN0qv1VnqzN7Ug710951Rho1tvhQoxLyGVBlZZ4mCPUmAlFeYaXh3aY4J/0YZg18IcHg I/WtGoK8l1NnoMHKsqAvbELXLvwpIJrlp/kQJkIn3m+/kl6uanXoqBsd38HtreGDuFY+ nuYQ== 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=t7NnMGwlWRDhlz/PioKMfrgEqxt5G8CiT2zntcHxSO0=; b=fSR1+KLkoHFhBgrmKh+YWz+a7OfJ/F/DN3vPbhoC5PsFooW0oiugYzy1k5Tr9NgLu2 Btitw3neaG+1H93BkLrca6lcL9RQcUBCG+5GpC4n3PINGWGZ5ES6k3JsRDC1HoscJS/9 3w+HejWrFQ3f/RSQ1nOuVjVicLGJV0R9NyswBqV3w3m9bWIPKsB2v0rQiXc0kxHFfcOI SaZUcIn+P5HFGY4So8xYPaGgGdJPyx13v8b/vgZosH83sa2CmD4hgJ73jdpNH0VTP8YQ k/Bc6lhNmRmipDW8cNLv1jblQ6yd/bMWUX9CM4uOzf6k1tacMcUw0SAOWH59BzhJJsXA +uIw== X-Gm-Message-State: ANhLgQ32T5gH2jPJUzBipEE+K1w71B+T0OH8HeYGauUzTL8bVKLQkJgb ppbsl5OyczyHB2skNMWrO0MehQ== X-Google-Smtp-Source: ADFU+vuSU1CvPfWLYRdHWnJa1t9Mk1D5bEd/2GE6giBOApAaqcAvjPRiyhk9nzLw5DMf8QKCwSY5aw== X-Received: by 2002:a37:5647:: with SMTP id k68mr9156950qkb.33.1585512737799; Sun, 29 Mar 2020 13:12:17 -0700 (PDT) Received: from pryzbyj (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id i186sm8862776qke.5.2020.03.29.13.12.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 29 Mar 2020 13:12:17 -0700 (PDT) Received: by pryzbyj (Postfix, from userid 1000) id 5B0F18011F5; Sun, 29 Mar 2020 15:12:15 -0500 (CDT) Date: Sun, 29 Mar 2020 15:12:15 -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: <20200329201215.GM20103@telsasoft.com> References: <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> <28906.1585422475@sss.pgh.pa.us> <27064.1585499825@sss.pgh.pa.us> <20200329171415.GL20103@telsasoft.com> <29512.1585502524@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <29512.1585502524@sss.pgh.pa.us> User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Sun, Mar 29, 2020 at 01:22:04PM -0400, Tom Lane wrote: > Justin Pryzby writes: > > On Sun, Mar 29, 2020 at 12:37:05PM -0400, Tom Lane wrote: > >> After looking at the callers of pg_ls_dir_files, and noticing that > >> it's already defined to ignore anything that's not a regular file, > >> I think switching to lstat makes sense. > > > Yea, only pg_ls_dir() shows special file types (and currently the others even > > hide dirs). > > > The essence of your patch is to ignore ENOENT, but you also changed to use > > lstat(), which seems unrelated. That means we'll now hide (non-broken) > > symlinks. Is that intentional/needed ? > > Well, the following comment says "ignore anything but regular files", > so I'm supposing that that is the behavior that we actually want here > and failed to implement correctly. There might be scope for > additional directory-reading functions, but I'd think you'd want > more information (such as the file type) returned from anything > that doesn't act this way. Maybe pg_stat_file() deserves similar attention ? Right now, it'll fail on a broken link. If we changed it to lstat(), then it'd work, but it'd also show metadata for the *link* rather than its target. Patch proposed as v14-0001 patch here may be relevant: https://www.postgresql.org/message-id/20200317190401.GY26184%40telsasoft.com - indicating if it is a directory. Typical usages include: + indicating if it is a directory (or a symbolic link to a directory). ... > In practice, since these directories shouldn't contain symlinks, > it's likely moot. The only place in PG data directories where > we actually expect symlinks is pg_tablespace ... and that contains > symlinks to directories, so that this function would ignore them > anyway. I wouldn't hesitate to make symlinks, at least in log. It's surprising when files are hidden, but I won't argue about the best behavior here. I'm thinking of distributions or local configurations that use /var/log/postgresql. I didn't remember or didn't realize, but it looks like debian's packages use logging_collector=off and then launch postmaster with 2> /var/log/postgres/... It seems reasonable to do something like: log/huge-querylog.csv => /zfs/compressed/... -- Justin