Commit 1e875138 authored by Alvaro Herrera's avatar Alvaro Herrera

Make new replication slot test code even less racy

Further fix the test code in ead9e51e8236, this time by waiting until
the checkpoint has completed before moving on; this ensures that the
WAL segment removal has already happened when we create the next slot.

Author: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Discussion: https://postgr.es/m/20210719.111318.2042379313472032754.horikyota.ntt@gmail.com
parent 40295d15
...@@ -11,7 +11,7 @@ use TestLib; ...@@ -11,7 +11,7 @@ use TestLib;
use PostgresNode; use PostgresNode;
use File::Path qw(rmtree); use File::Path qw(rmtree);
use Test::More tests => $TestLib::windows_os ? 15 : 19; use Test::More tests => $TestLib::windows_os ? 16 : 20;
use Time::HiRes qw(usleep); use Time::HiRes qw(usleep);
$ENV{PGDATABASE} = 'postgres'; $ENV{PGDATABASE} = 'postgres';
...@@ -201,6 +201,19 @@ $result = $node_primary->safe_psql( ...@@ -201,6 +201,19 @@ $result = $node_primary->safe_psql(
is($result, "rep1|f|t|lost|", is($result, "rep1|f|t|lost|",
'check that the slot became inactive and the state "lost" persists'); 'check that the slot became inactive and the state "lost" persists');
# Wait until current checkpoint ends
my $checkpoint_ended = 0;
for (my $i = 0; $i < 10000; $i++)
{
if (find_in_log($node_primary, "checkpoint complete: ", $logstart))
{
$checkpoint_ended = 1;
last;
}
usleep(100_000);
}
ok($checkpoint_ended, 'waited for checkpoint to end');
# The invalidated slot shouldn't keep the old-segment horizon back; # The invalidated slot shouldn't keep the old-segment horizon back;
# see bug #17103: https://postgr.es/m/17103-004130e8f27782c9@postgresql.org # see bug #17103: https://postgr.es/m/17103-004130e8f27782c9@postgresql.org
# Test for this by creating a new slot and comparing its restart LSN # Test for this by creating a new slot and comparing its restart LSN
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment