Skip to content

Commit 8589299

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 665c585 commit 8589299

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
@@ -177,18 +177,21 @@
177177
my $logstart = get_log_size($node_primary);
178178
advance_wal($node_primary, 7);
179179

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

193196
$result = $node_primary->safe_psql(
194197
'postgres',

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy