Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit82e8018

Browse files
committed
Teach pg_ls_dir_files() to ignore ENOENT failures from stat().
Buildfarm experience shows that this function can fail with ENOENTif some other process unlinks a file between when we read the directoryentry and when we try to stat() it. The problem is old but we hadnot noticed it until085b6b6 added regression test coverage.To fix, just ignore ENOENT failures. There is one other case thatthis might hide: a symlink that points to nowhere. That seems okaythough, at least better than erroring.Back-patch to v10 where this function was added, since the regressiontest cases were too.Discussion:https://postgr.es/m/20200308173103.GC1357@telsasoft.com
1 parent70dc4c5 commit82e8018

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

‎src/backend/utils/adt/genfile.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,9 +597,14 @@ pg_ls_dir_files(FunctionCallInfo fcinfo, const char *dir, bool missing_ok)
597597
/* Get the file info */
598598
snprintf(path,sizeof(path),"%s/%s",dir,de->d_name);
599599
if (stat(path,&attrib)<0)
600+
{
601+
/* Ignore concurrently-deleted files, else complain */
602+
if (errno==ENOENT)
603+
continue;
600604
ereport(ERROR,
601605
(errcode_for_file_access(),
602606
errmsg("could not stat file \"%s\": %m",path)));
607+
}
603608

604609
/* Ignore anything but regular files */
605610
if (!S_ISREG(attrib.st_mode))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp