mirror of
https://github.com/postgres/postgres.git
synced 2026-04-28 17:49:35 -04:00
Improve more stability of worker_spi termination test
Alexander Lakhin has noticed that it can be possible on machines with slow storage to have the spawned workers be stuck in initialize_worker_spi(), before they reach their main loop. Waiting for a flush to happen would block the interrupt attempts done by the database commands, causing the test to fail on timeout once the number of interrupt attempts is reached in CountOtherDBBackends(). This commit switches the test to wait for the spawned bgworkers to reach their main loops before attempting the database commands that would trigger the interrupts, napping for a time larger than the default, with worker_spi.naptime set at 10 minutes. Another thing that could be attempted is to enforce a larger number of tries in CountOtherDBBackends(), if what is done here is not enough. Let's see first if what this commit does is enough for the buildfarm members widowbird and jay. Analyzed-by: Alexander Lakhin <exclusion@gmail.com> Discussion: https://postgr.es/m/f913fba1-da59-404c-9eb3-07c7304be637@gmail.com
This commit is contained in:
parent
d78a4f0bf0
commit
283c5fb22b
1 changed files with 10 additions and 8 deletions
|
|
@ -20,7 +20,6 @@ if ($ENV{enable_injection_points} ne 'yes')
|
|||
sub launch_bgworker
|
||||
{
|
||||
my ($node, $database, $testcase, $interruptible) = @_;
|
||||
my $offset = -s $node->logfile;
|
||||
|
||||
# Launch a background worker on the given database.
|
||||
my $pid = $node->safe_psql(
|
||||
|
|
@ -28,13 +27,12 @@ sub launch_bgworker
|
|||
SELECT worker_spi_launch($testcase, '$database'::regdatabase, 0, '{}', $interruptible);
|
||||
));
|
||||
|
||||
# Check that the bgworker is initialized.
|
||||
$node->wait_for_log(
|
||||
qr/LOG: .*worker_spi dynamic worker $testcase initialized with .*\..*/,
|
||||
$offset);
|
||||
my $result = $node->safe_psql('postgres',
|
||||
"SELECT count(*) > 0 FROM pg_stat_activity WHERE pid = $pid;");
|
||||
is($result, 't', "dynamic bgworker $testcase launched");
|
||||
# Check that the bgworker is initialized and napping.
|
||||
my $result =
|
||||
$node->poll_query_until('postgres',
|
||||
qq[SELECT wait_event FROM pg_stat_activity WHERE pid = $pid;],
|
||||
qq[WorkerSpiMain]);
|
||||
is($result, 1, "dynamic bgworker $testcase launched");
|
||||
|
||||
return $pid;
|
||||
}
|
||||
|
|
@ -64,11 +62,15 @@ sub run_bgworker_interruptible_test
|
|||
|
||||
my $node = PostgreSQL::Test::Cluster->new('mynode');
|
||||
$node->init;
|
||||
# The naptime is large enough to give some room on slow machines, so as
|
||||
# the spawned workers have the time to process the interrupt requests sent
|
||||
# by the database commands.
|
||||
$node->append_conf(
|
||||
"postgresql.conf", qq(
|
||||
autovacuum = off
|
||||
debug_parallel_query = off
|
||||
log_min_messages = debug1
|
||||
worker_spi.naptime = 600
|
||||
));
|
||||
$node->start;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue