aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2022-01-19 16:29:09 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2022-01-19 16:29:09 -0500
commitb0623625a0a30d66e991deab6488c59bb63ea20e (patch)
treebf8c07900871fb257d6c5cdf4e27ac9afd4df6ea /src
parent0f1367c9f381aae523f6557c0ee28a800b3eace7 (diff)
downloadpostgresql-b0623625a0a30d66e991deab6488c59bb63ea20e.tar.gz
postgresql-b0623625a0a30d66e991deab6488c59bb63ea20e.zip
TAP tests: check for postmaster.pid anyway when "pg_ctl start" fails.
"pg_ctl start" might start a new postmaster and then return failure anyway, for example if PGCTLTIMEOUT is exceeded. If there is a postmaster there, it's still incumbent on us to shut it down at script end, so check for the PID file even though we are about to fail. This has been broken all along, so back-patch to all supported branches. Discussion: https://postgr.es/m/647439.1642622744@sss.pgh.pa.us
Diffstat (limited to 'src')
-rw-r--r--src/test/perl/PostgresNode.pm14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/test/perl/PostgresNode.pm b/src/test/perl/PostgresNode.pm
index 0d7c0b1f364..9043fee2fc5 100644
--- a/src/test/perl/PostgresNode.pm
+++ b/src/test/perl/PostgresNode.pm
@@ -812,6 +812,11 @@ sub start
{
print "# pg_ctl start failed; logfile:\n";
print TestLib::slurp_file($self->logfile);
+
+ # pg_ctl could have timed out, so check to see if there's a pid file;
+ # otherwise our END block will fail to shut down the new postmaster.
+ $self->_update_pid(-1);
+
BAIL_OUT("pg_ctl start failed") unless $params{fail_ok};
return 0;
}
@@ -1088,7 +1093,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) = @_;
@@ -1103,7 +1111,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;
}
@@ -1111,7 +1119,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;
}