Skip to content

Commit 36c1c91

Browse files
committed
Make regression test for multiple synchronous standbys more stable.
The regression test checks whether the output of pg_stat_replication is expected or not after changing synchronous_standby_names and reloading the configuration file. Regarding this test logic, previously there was a timing issue which made the test result unstable. That is, pg_stat_replication could return unexpected result during small window after the configuration file was reloaded before new setting value took effect, and which made the test fail. This commit changes the test logic so that it uses a loop with a timeout to give some room for the test to pass. Now the test fails only when pg_stat_replication keeps returning unexpected result for 30 seconds. Michael Paquier
1 parent f0e766b commit 36c1c91

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/test/recovery/t/007_sync_rep.pl

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,23 @@ sub test_sync_state
2222
$self->reload;
2323
}
2424

25-
my $result = $self->safe_psql('postgres', $check_sql);
25+
my $timeout_max = 30;
26+
my $timeout = 0;
27+
my $result;
28+
29+
# A reload may take some time to take effect on busy machines,
30+
# hence use a loop with a timeout to give some room for the test
31+
# to pass.
32+
while ($timeout < $timeout_max)
33+
{
34+
$result = $self->safe_psql('postgres', $check_sql);
35+
36+
last if ($result eq $expected);
37+
38+
$timeout++;
39+
sleep 1;
40+
}
41+
2642
is($result, $expected, $msg);
2743
}
2844

0 commit comments

Comments
 (0)