Skip to content

Commit 0d2cb6b

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 344dedf commit 0d2cb6b

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

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

+14-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use PostgresNode;
1212

1313
use File::Path qw(rmtree);
14-
use Test::More tests => $TestLib::windows_os ? 15 : 19;
14+
use Test::More tests => $TestLib::windows_os ? 16 : 20;
1515
use Time::HiRes qw(usleep);
1616

1717
$ENV{PGDATABASE} = 'postgres';
@@ -201,6 +201,19 @@
201201
is($result, "rep1|f|t|lost|",
202202
'check that the slot became inactive and the state "lost" persists');
203203

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

0 commit comments

Comments
 (0)