Skip to content

Commit ce413eb

Browse files
committed
Make new replication slot test code even less racy
Further fix the test code in ead9e51, 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
1 parent bfa2a92 commit ce413eb

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/test/recovery/t/019_replslot_limit.pl

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use PostgresNode;
99

1010
use File::Path qw(rmtree);
11-
use Test::More tests => 15;
11+
use Test::More tests => 16;
1212
use Time::HiRes qw(usleep);
1313

1414
$ENV{PGDATABASE} = 'postgres';
@@ -198,6 +198,19 @@
198198
is($result, "rep1|f|t|lost|",
199199
'check that the slot became inactive and the state "lost" persists');
200200

201+
# Wait until current checkpoint ends
202+
my $checkpoint_ended = 0;
203+
for (my $i = 0; $i < 10000; $i++)
204+
{
205+
if (find_in_log($node_master, "checkpoint complete: ", $logstart))
206+
{
207+
$checkpoint_ended = 1;
208+
last;
209+
}
210+
usleep(100_000);
211+
}
212+
ok($checkpoint_ended, 'waited for checkpoint to end');
213+
201214
# The invalidated slot shouldn't keep the old-segment horizon back;
202215
# see bug #17103: https://postgr.es/m/17103-004130e8f27782c9@postgresql.org
203216
# Test for this by creating a new slot and comparing its restart LSN

0 commit comments

Comments
 (0)