Skip to content

Commit 7099ba0

Browse files
committed
Make new replication slot test code less racy
The new test code added in ead9e51 is racy -- it hinges on shared-memory state, which changes before the WARNING message is logged. Put it the other way around. Backpatch to 13. Author: Álvaro Herrera <alvherre@alvh.no-ip.org> Discussion: https://postgr.es/m/202107161809.zclasccpfcg3@alvherre.pgsql
1 parent 35e9d26 commit 7099ba0

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

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

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -174,18 +174,21 @@
174174
my $logstart = get_log_size($node_master);
175175
advance_wal($node_master, 7);
176176

177-
# This slot should be broken, wait for that to happen
178-
$node_master->poll_query_until(
179-
'postgres',
180-
qq[SELECT wal_status = 'lost' FROM pg_replication_slots
181-
WHERE slot_name = 'rep1']);
182-
183-
# WARNING should be issued
184-
ok( find_in_log(
185-
$node_master,
186-
"invalidating slot \"rep1\" because its restart_lsn [0-9A-F/]+ exceeds max_slot_wal_keep_size",
187-
$logstart),
188-
'check that the warning is logged');
177+
# wait until the WARNING is issued
178+
my $invalidated = 0;
179+
for (my $i = 0; $i < 10000; $i++)
180+
{
181+
if (find_in_log(
182+
$node_master,
183+
"invalidating slot \"rep1\" because its restart_lsn [0-9A-F/]+ exceeds max_slot_wal_keep_size",
184+
$logstart))
185+
{
186+
$invalidated = 1;
187+
last;
188+
}
189+
usleep(100_000);
190+
}
191+
ok($invalidated, 'check that slot invalidation has been logged');
189192

190193
$result = $node_master->safe_psql(
191194
'postgres',

0 commit comments

Comments
 (0)