check-for-postmaster-even-after-pg_ctl-failure.patch
text/x-diff
Filename: check-for-postmaster-even-after-pg_ctl-failure.patch
Type: text/x-diff
Part: 0
Message:
Re: Adding CI to our tree
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: unified
| File | + | − |
|---|---|---|
| src/test/perl/PostgreSQL/Test/Cluster.pm | 11 | 3 |
diff --git a/src/test/perl/PostgreSQL/Test/Cluster.pm b/src/test/perl/PostgreSQL/Test/Cluster.pm
index 7af0f8db13..fd0738d12d 100644
--- a/src/test/perl/PostgreSQL/Test/Cluster.pm
+++ b/src/test/perl/PostgreSQL/Test/Cluster.pm
@@ -845,6 +845,11 @@ sub start
{
print "# pg_ctl start failed; logfile:\n";
print PostgreSQL::Test::Utils::slurp_file($self->logfile);
+
+ # pg_ctl could have timed out, so check to see if there's a pid file;
+ # without this, we fail to shut down the new postmaster later.
+ $self->_update_pid(-1);
+
BAIL_OUT("pg_ctl start failed") unless $params{fail_ok};
return 0;
}
@@ -1123,7 +1128,10 @@ archive_command = '$copy_command'
return;
}
-# Internal method
+# Internal method to update $self->{_pid}
+# $is_running = 1: pid file should be there
+# $is_running = 0: pid file should NOT be there
+# $is_running = -1: we aren't sure
sub _update_pid
{
my ($self, $is_running) = @_;
@@ -1138,7 +1146,7 @@ sub _update_pid
close $pidfile;
# If we found a pidfile when there shouldn't be one, complain.
- BAIL_OUT("postmaster.pid unexpectedly present") unless $is_running;
+ BAIL_OUT("postmaster.pid unexpectedly present") if $is_running == 0;
return;
}
@@ -1146,7 +1154,7 @@ sub _update_pid
print "# No postmaster PID for node \"$name\"\n";
# Complain if we expected to find a pidfile.
- BAIL_OUT("postmaster.pid unexpectedly not present") if $is_running;
+ BAIL_OUT("postmaster.pid unexpectedly not present") if $is_running == 1;
return;
}