Race condition when starting and stopping test server in TestLib.pm?

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Race condition when starting and stopping test server in TestLib.pm?
Date: 2015-05-01 06:47:25
Message-ID: CAB7nPqR_5Y=kHHR4RwCZaoqoe_bCnkLgtjX1VnY7WEBSv-JVVw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi all,

Within the last couple of days hamster has failed twice when running
TAP tests because it was not able to start a test server with
start_test_server:
http://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=hamster&dt=2015-04-30%2019%3A07%3A31
http://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=hamster&dt=2015-04-22%2016%3A00%3A33

And here is the failure:
pg_ctl: could not start server
Examine the log output.
Bailout called. Further testing stopped: pg_ctl failed
cannot remove directory for
/home/buildfarm/data/buildroot/HEAD/pgsql.build/src/bin/scripts/tmp_testrTRB/pgdata:
Directory not empty at /usr/share/perl5/core_perl/File/Temp.pm line
784.
cannot remove directory for
/home/buildfarm/data/buildroot/HEAD/pgsql.build/src/bin/scripts/tmp_testrTRB:
Directory not empty at /usr/share/perl5/core_perl/File/Temp.pm line
784.

When connecting to the server this afternoon I noticed that indeed
that an instance of Postgres was still running, and visibly it has
been been able to stop because the temporary data directory has been
removed before the server stop really completed. Note that I stopped
it brutally for now to allow the next rounds of tests to work btw...

hamster is now known to be legendary slow in the buildfarm, so I guess
that it is good in catching up such race conditions, hence I am
wondering if the failure is not caused by one even if switch -w is
used when stopping the server in TestLib.pm.
END
{
if ($test_server_datadir)
{
system 'pg_ctl', '-D', $test_server_datadir, '-s', '-w', '-m',
'immediate', 'stop';
}
}
Thoughts?
--
Michael

Browse pgsql-hackers by date

  From Date Subject
Next Message Sawada Masahiko 2015-05-01 09:58:23 Re: Auditing extension for PostgreSQL (Take 2)
Previous Message Kyotaro HORIGUCHI 2015-05-01 06:31:50 Re: alter user/role CURRENT_USER