Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit c85ad9c

Browse files
committed
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.
1 parent 076a3c2 commit c85ad9c

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

src/test/perl/TestLib.pm

+17-4
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,6 @@ sub check_mode_recursive
261261
{
262262
follow_fast => 1,
263263
wanted => sub {
264-
my $file_stat = stat($File::Find::name);
265-
266264
# Is file in the ignore list?
267265
foreach my $ignore ($ignore_list ? @{$ignore_list} : [])
268266
{
@@ -272,8 +270,23 @@ sub check_mode_recursive
272270
}
273271
}
274272

275-
defined($file_stat)
276-
or die("unable to stat $File::Find::name");
273+
# Allow ENOENT. A running server can delete files, such as
274+
# those in pg_stat. Other stat() failures are fatal.
275+
my $file_stat = stat($File::Find::name);
276+
unless (defined($file_stat))
277+
{
278+
my $is_ENOENT = $!{ENOENT};
279+
my $msg = "unable to stat $File::Find::name: $!";
280+
if ($is_ENOENT)
281+
{
282+
warn $msg;
283+
return;
284+
}
285+
else
286+
{
287+
die $msg;
288+
}
289+
}
277290

278291
my $file_mode = S_IMODE($file_stat->mode);
279292

0 commit comments

Comments
 (0)