Commit c85ad9cc authored by Noah Misch's avatar Noah Misch

Allow ENOENT in check_mode_recursive().

Buildfarm member tern failed src/bin/pg_ctl/t/001_start_stop.pl when a
check_mode_recursive() call overlapped a server's startup-time deletion
of pg_stat/global.stat.  Just warn.  Also, include errno in the message.
Back-patch to v11, where check_mode_recursive() first appeared.
parent 076a3c21
...@@ -261,8 +261,6 @@ sub check_mode_recursive ...@@ -261,8 +261,6 @@ sub check_mode_recursive
{ {
follow_fast => 1, follow_fast => 1,
wanted => sub { wanted => sub {
my $file_stat = stat($File::Find::name);
# Is file in the ignore list? # Is file in the ignore list?
foreach my $ignore ($ignore_list ? @{$ignore_list} : []) foreach my $ignore ($ignore_list ? @{$ignore_list} : [])
{ {
...@@ -272,8 +270,23 @@ sub check_mode_recursive ...@@ -272,8 +270,23 @@ sub check_mode_recursive
} }
} }
defined($file_stat) # Allow ENOENT. A running server can delete files, such as
or die("unable to stat $File::Find::name"); # those in pg_stat. Other stat() failures are fatal.
my $file_stat = stat($File::Find::name);
unless (defined($file_stat))
{
my $is_ENOENT = $!{ENOENT};
my $msg = "unable to stat $File::Find::name: $!";
if ($is_ENOENT)
{
warn $msg;
return;
}
else
{
die $msg;
}
}
my $file_mode = S_IMODE($file_stat->mode); my $file_mode = S_IMODE($file_stat->mode);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment