Permalink
Browse files

Add check for rogue postmasters.

  • Loading branch information...
1 parent 4631f13 commit 07abea63b76248235e76d67d85237299407485b0 @adunstan adunstan committed Jan 13, 2013
Showing with 46 additions and 1 deletion.
  1. +6 −0 PGBuild/Modules/TestUpgrade.pm
  2. +40 −1 run_build.pl
@@ -65,6 +65,12 @@ sub check
my $make = $self->{bfconf}->{make};
+ local %ENV = %ENV;
+ delete $ENV{PGUSER};
+
+ (my $buildport = $ENV{EXTRA_REGRESS_OPTS}) =~ s/--port=//;
+ $ENV{PGPORT} = $buildport;
+
my @checklog;
if ($self->{bfconf}->{using_msvc})
View
@@ -36,6 +36,7 @@
use strict;
use warnings;
+use Config;
use Fcntl qw(:flock :seek);
use File::Path;
use File::Copy;
@@ -195,6 +196,8 @@ BEGIN
$buildport = $PGBuild::conf{branch_ports}->{$branch} || 5999;
}
+$ENV{EXTRA_REGRESS_OPTS} = "--port=$buildport";
+
$tar_log_cmd ||= "tar -z -cf runlogs.tgz *.log";
my $logdirname = "lastrun-logs";
@@ -499,6 +502,8 @@ END
$ENV{PGUSER} = 'buildfarm';
+check_port_is_ok($buildport, 'Pre');
+
if ($from_source_clean)
{
print time_str(),"cleaning source in $pgsql ...\n";
@@ -751,6 +756,8 @@ END
find_typedefs();
}
+check_port_is_ok($buildport,'Post');
+
# if we get here everything went fine ...
my $saved_config = get_config_summary();
@@ -1766,7 +1773,7 @@ sub send_result
}
}
- if ($stage !~ /CVS|Git|SCM/ )
+ if ($stage !~ /CVS|Git|SCM|Pre-run-port-check/ )
{
my @logfiles = glob("$lrname/*.log");
@@ -1875,6 +1882,38 @@ sub get_config_summary
return $config;
}
+sub check_port_is_ok
+{
+ my $port = shift;
+ my $report = shift; # Pre or Post
+ my $stage = "${report}-run-port-check";
+ my @log;
+ my $found = undef;
+
+ if ($Config{osname} !~ /msys|MSWin/)
+ {
+
+ # look for a unix socket except on Windows -
+ # cygwin does have them, though
+ # could connect, but just finding the socket file should do,
+ # since its existence will cause us grief.
+ $found = -S "/tmp/.s.PGSQL.$port";
+ }
+ if ($found)
+ {
+
+ # If we want to kill the process, do something likethis,
+ # but only in a Post checvk - don't kill any pre-existing
+ # process on the port:
+ # system("fuser -k /tmp/.s.PGSQL.$port") if $report eq 'Post';
+
+ # In either case finding this process is an error, so call
+ # send_result.
+ push(@log,"socket found listening to port $port");
+ send_result($stage,99,\@log);
+ }
+}
+
sub get_script_config_dump
{
my $conf = {

0 comments on commit 07abea6

Please sign in to comment.