public inbox for [email protected]  
help / color / mirror / Atom feed
From: Zakariyah Ali <[email protected]>
To: [email protected]
Cc: Zakariyah Ali <[email protected]>
Subject: [PATCH] Fix loose polling in 019_replslot_limit.pl test
Date: Sat,  6 Jun 2026 21:32:22 +0100
Message-ID: <[email protected]> (raw)

Signed-off-by: Zakariyah Ali <[email protected]>
---
 src/test/recovery/t/019_replslot_limit.pl | 78 +++++------------------
 1 file changed, 16 insertions(+), 62 deletions(-)

diff --git a/src/test/recovery/t/019_replslot_limit.pl b/src/test/recovery/t/019_replslot_limit.pl
index a412faf51c6..3fdce739965 100644
--- a/src/test/recovery/t/019_replslot_limit.pl
+++ b/src/test/recovery/t/019_replslot_limit.pl
@@ -186,18 +186,9 @@ $node_primary->advance_wal(7);
 $node_primary->safe_psql('postgres',
 	'ALTER SYSTEM RESET max_wal_size; SELECT pg_reload_conf()');
 $node_primary->safe_psql('postgres', "CHECKPOINT;");
-my $invalidated = 0;
-for (my $i = 0; $i < 10 * $PostgreSQL::Test::Utils::timeout_default; $i++)
-{
-	if ($node_primary->log_contains(
-			'invalidating obsolete replication slot "rep1"', $logstart))
-	{
-		$invalidated = 1;
-		last;
-	}
-	usleep(100_000);
-}
-ok($invalidated, 'check that slot invalidation has been logged');
+ok( $node_primary->wait_for_log(
+		'invalidating obsolete replication slot "rep1"', $logstart),
+	'check that slot invalidation has been logged');
 
 $result = $node_primary->safe_psql(
 	'postgres',
@@ -208,17 +199,8 @@ is($result, "rep1|f|t|lost|",
 	'check that the slot became inactive and the state "lost" persists');
 
 # Wait until current checkpoint ends
-my $checkpoint_ended = 0;
-for (my $i = 0; $i < 10 * $PostgreSQL::Test::Utils::timeout_default; $i++)
-{
-	if ($node_primary->log_contains("checkpoint complete: ", $logstart))
-	{
-		$checkpoint_ended = 1;
-		last;
-	}
-	usleep(100_000);
-}
-ok($checkpoint_ended, 'waited for checkpoint to end');
+ok( $node_primary->wait_for_log("checkpoint complete: ", $logstart),
+	'waited for checkpoint to end');
 
 # The invalidated slot shouldn't keep the old-segment horizon back;
 # see bug #17103: https://postgr.es/m/[email protected]
@@ -238,18 +220,10 @@ is($oldestseg, $redoseg, "check that segments have been removed");
 $logstart = -s $node_standby->logfile;
 $node_standby->start;
 
-my $failed = 0;
-for (my $i = 0; $i < 10 * $PostgreSQL::Test::Utils::timeout_default; $i++)
-{
-	if ($node_standby->log_contains(
-			"This replication slot has been invalidated due to \"wal_removed\".",
-			$logstart))
-	{
-		$failed = 1;
-		last;
-	}
-	usleep(100_000);
-}
+my $failed =
+  $node_standby->wait_for_log(
+	"This replication slot has been invalidated due to \"wal_removed\".",
+	$logstart);
 ok($failed, 'check that replication has been broken');
 
 $node_primary->stop;
@@ -374,20 +348,10 @@ $logstart = -s $node_primary3->logfile;
 kill 'STOP', $senderpid, $receiverpid;
 $node_primary3->advance_wal(2);
 
-my $msg_logged = 0;
-my $max_attempts = $PostgreSQL::Test::Utils::timeout_default;
-while ($max_attempts-- >= 0)
-{
-	if ($node_primary3->log_contains(
-			"terminating process $senderpid to release replication slot \"rep3\"",
-			$logstart))
-	{
-		$msg_logged = 1;
-		last;
-	}
-	sleep 1;
-}
-ok($msg_logged, "walsender termination logged");
+ok( $node_primary3->wait_for_log(
+		"terminating process $senderpid to release replication slot \"rep3\"",
+		$logstart),
+	"walsender termination logged");
 
 # Now let the walsender continue; slot should be killed now.
 # (Must not let walreceiver run yet; otherwise the standby could start another
@@ -398,19 +362,9 @@ $node_primary3->poll_query_until('postgres',
 	"lost")
   or die "timed out waiting for slot to be lost";
 
-$msg_logged = 0;
-$max_attempts = $PostgreSQL::Test::Utils::timeout_default;
-while ($max_attempts-- >= 0)
-{
-	if ($node_primary3->log_contains(
-			'invalidating obsolete replication slot "rep3"', $logstart))
-	{
-		$msg_logged = 1;
-		last;
-	}
-	sleep 1;
-}
-ok($msg_logged, "slot invalidation logged");
+ok( $node_primary3->wait_for_log(
+		'invalidating obsolete replication slot "rep3"', $logstart),
+	"slot invalidation logged");
 
 # Now let the walreceiver continue, so that the node can be stopped cleanly
 kill 'CONT', $receiverpid;
-- 
2.43.0







view thread (4+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: [PATCH] Fix loose polling in 019_replslot_limit.pl test
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox