aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2021-07-17 13:19:17 -0400
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2021-07-17 13:19:17 -0400
commitd8f3b021c618bf58c19f88fb86476793fd650336 (patch)
treebcacfa0b39e5c581fc89ca7f5a1f24fe570704d5
parent4466b38ec6ffd4ddea135c5baff978b7b43f8257 (diff)
downloadpostgresql-d8f3b021c618bf58c19f88fb86476793fd650336.tar.gz
postgresql-d8f3b021c618bf58c19f88fb86476793fd650336.zip
Make new replication slot test code less racy
The new test code added in ead9e51e8236 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
-rw-r--r--src/test/recovery/t/019_replslot_limit.pl27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/test/recovery/t/019_replslot_limit.pl b/src/test/recovery/t/019_replslot_limit.pl
index f1a00c67f22..026da02ff15 100644
--- a/src/test/recovery/t/019_replslot_limit.pl
+++ b/src/test/recovery/t/019_replslot_limit.pl
@@ -177,18 +177,21 @@ ok( !find_in_log(
my $logstart = get_log_size($node_primary);
advance_wal($node_primary, 7);
-# This slot should be broken, wait for that to happen
-$node_primary->poll_query_until(
- 'postgres',
- qq[SELECT wal_status = 'lost' FROM pg_replication_slots
- WHERE slot_name = 'rep1']);
-
-# WARNING should be issued
-ok( find_in_log(
- $node_primary,
- "invalidating slot \"rep1\" because its restart_lsn [0-9A-F/]+ exceeds max_slot_wal_keep_size",
- $logstart),
- 'check that the warning is logged');
+# wait until the WARNING is issued
+my $invalidated = 0;
+for (my $i = 0; $i < 10000; $i++)
+{
+ if (find_in_log(
+ $node_primary,
+ "invalidating slot \"rep1\" because its restart_lsn [0-9A-F/]+ exceeds max_slot_wal_keep_size",
+ $logstart))
+ {
+ $invalidated = 1;
+ last;
+ }
+ usleep(100_000);
+}
+ok($invalidated, 'check that slot invalidation has been logged');
$result = $node_primary->safe_psql(
'postgres',