Teach pg_ls_dir_files() to ignore ENOENT failures from stat().
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 31 Mar 2020 16:57:55 +0000 (12:57 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 31 Mar 2020 16:57:55 +0000 (12:57 -0400)
commit5b22ff764b0f60c24d89ec0180476cda361ec126
treede67f948d319b6d4bb6d39a04d9b58d536da53a9
parentfade4d4dffca760252c0d7ee69598e7b441ed2f4
Teach pg_ls_dir_files() to ignore ENOENT failures from stat().

Buildfarm experience shows that this function can fail with ENOENT
if some other process unlinks a file between when we read the directory
entry and when we try to stat() it.  The problem is old but we had
not noticed it until 085b6b667 added regression test coverage.

To fix, just ignore ENOENT failures.  There is one other case that
this might hide: a symlink that points to nowhere.  That seems okay
though, at least better than erroring.

Back-patch to v10 where this function was added, since the regression
test cases were too.

Discussion: https://postgr.es/m/20200308173103.GC1357@telsasoft.com
src/backend/utils/adt/genfile.c