diff --git a/src/backend/utils/adt/genfile.c b/src/backend/utils/adt/genfile.c index 2a03385e109..7c1e81e4504 100644 --- a/src/backend/utils/adt/genfile.c +++ b/src/backend/utils/adt/genfile.c @@ -581,9 +581,14 @@ pg_ls_dir_files(FunctionCallInfo fcinfo, const char *dir) /* Get the file info */ snprintf(path, sizeof(path), "%s/%s", dir, de->d_name); if (stat(path, &attrib) < 0) + { + /* Ignore concurrently-deleted files, else complain */ + if (errno == ENOENT) + continue; ereport(ERROR, (errcode_for_file_access(), errmsg("could not stat file \"%s\": %m", path))); + } /* Ignore anything but regular files */ if (!S_ISREG(attrib.st_mode))