Re: pg11+: pg_ls_*dir LIMIT 1: temporary files .. not closed at end-of-transaction
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Justin Pryzby <pryzby@telsasoft.com>
Cc: pgsql-hackers@postgresql.org, Fabien COELHO <coelho@cri.ensmp.fr>,
Alvaro Herrera <alvherre@2ndquadrant.com>,
David Steele <david@pgmasters.net>,
"Bossart,
Nathan" <bossartn@amazon.com>,
Thomas Munro <thomas.munro@gmail.com>
Date: 2020-03-28T19:07:55Z
Lists: pgsql-hackers
Justin Pryzby <pryzby@telsasoft.com> 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; if > lstat() fails, then skip it. Currently, we use stat(), which shows metdata 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 the 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=no, which 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
Commits
-
Teach pg_ls_dir_files() to ignore ENOENT failures from stat().
- ee40e8975e2c 12.3 landed
- 83f7761d84e6 10.13 landed
- 82e801852274 13.0 landed
- 5b22ff764b0f 11.8 landed
-
Remove useless pfree()s at the ends of various ValuePerCall SRFs.
- 41b45576d532 13.0 landed
-
Avoid holding a directory FD open across assorted SRF calls.
- cd6a0518794d 9.6.18 landed
- 5e4a0b7194b9 10.13 landed
- 819d5525744b 11.8 landed
- 2a89455aade3 12.3 landed
- b4570d33aa04 13.0 landed
- da254148f4de 9.5.22 landed
-
Document pg_ls_*dir hiding of directories and special files
- 8b6d94cf6c83 13.0 cited
-
Avoid holding a directory FD open across pg_ls_dir_files() calls.
- 05283dd5b579 10.13 landed
- 63b51dfec18e 11.8 landed
- 3c8864fc1c54 12.3 landed
- 085b6b6679e7 13.0 landed
-
Adjust nodeFunctionscan.c to reset transient memory context between calls
- e4186762ffaa 7.3.1 cited