pgsql: Teach pg_ls_dir_files() to ignore ENOENT failures from stat().

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Teach pg_ls_dir_files() to ignore ENOENT failures from stat().
Date: 2020-03-31 16:58:09
Message-ID: E1jJKDJ-0002em-3f@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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

Branch
------
REL_12_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/ee40e8975e2cd2811d14a35ce9179bd46e1f59f2

Modified Files
--------------
src/backend/utils/adt/genfile.c | 5 +++++
1 file changed, 5 insertions(+)

Browse pgsql-committers by date

  From Date Subject
Next Message Bruce Momjian 2020-03-31 18:17:37 pgsql: Allow ecpg to be built stand-alone, allow parallel libpq make
Previous Message Tom Lane 2020-03-31 15:38:22 pgsql: Back-patch addition of stack overflow and interrupt checks for l