Hi,

On Fri, Mar 01, 2024 at 11:02:01AM +0900, Michael Paquier wrote:
> On Thu, Feb 29, 2024 at 06:19:58PM +0500, Andrey M. Borodin wrote:
> > Works fine for me. Thanks!
> 
> +         "timed out waiting for the backend type to wait for the injection 
> point name";
> 
> The log should provide some context about the caller failing, meaning
> that the backend type and the injection point name should be mentioned
> in these logs to help in debugging issues.

Yeah, done in v3 attached.

Regards,

-- 
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com
>From ea354b9d0aeee34b9ba315735cce1e2ff1cb6532 Mon Sep 17 00:00:00 2001
From: Bertrand Drouvot <bertranddrouvot...@gmail.com>
Date: Thu, 29 Feb 2024 08:31:28 +0000
Subject: [PATCH v3] Adding wait_for_injection_point helper

---
 src/test/perl/PostgreSQL/Test/Cluster.pm      | 36 +++++++++++++++++++
 .../recovery/t/041_checkpoint_at_promote.pl   |  8 +----
 2 files changed, 37 insertions(+), 7 deletions(-)
  65.3% src/test/perl/PostgreSQL/Test/
  34.6% src/test/recovery/t/

diff --git a/src/test/perl/PostgreSQL/Test/Cluster.pm b/src/test/perl/PostgreSQL/Test/Cluster.pm
index 44c1bb5afd..8d92eb3858 100644
--- a/src/test/perl/PostgreSQL/Test/Cluster.pm
+++ b/src/test/perl/PostgreSQL/Test/Cluster.pm
@@ -2742,6 +2742,42 @@ sub lsn
 
 =pod
 
+=item $node->wait_for_injection_point(injection_name, backend_type)
+
+Wait for the backend_type to wait for the injection point name.
+
+=cut
+
+sub wait_for_injection_point
+{
+	my ($self, $injection_name, $backend_type) = @_;
+	my $die_message;
+
+	if (defined($backend_type))
+	{
+		$backend_type = qq('$backend_type');
+		$die_message = "the backend type $backend_type";
+	}
+	else
+	{
+		$backend_type = 'backend_type';
+		$die_message = 'one backend';
+
+	}
+
+	$self->poll_query_until(
+		'postgres', qq[
+		SELECT count(*) > 0 FROM pg_stat_activity
+		WHERE backend_type = $backend_type AND wait_event = '$injection_name'
+	])
+	  or die
+	  qq(timed out waiting for $die_message to wait for the injection point '$injection_name');
+
+	return;
+}
+
+=pod
+
 =item $node->wait_for_catchup(standby_name, mode, target_lsn)
 
 Wait for the replication connection with application_name standby_name until
diff --git a/src/test/recovery/t/041_checkpoint_at_promote.pl b/src/test/recovery/t/041_checkpoint_at_promote.pl
index 47381a2c82..3d6faabc0b 100644
--- a/src/test/recovery/t/041_checkpoint_at_promote.pl
+++ b/src/test/recovery/t/041_checkpoint_at_promote.pl
@@ -79,13 +79,7 @@ $node_primary->wait_for_replay_catchup($node_standby);
 # Wait until the checkpointer is in the middle of the restart point
 # processing, relying on the custom wait event generated in the
 # wait callback used in the injection point previously attached.
-ok( $node_standby->poll_query_until(
-		'postgres',
-		qq[SELECT count(*) FROM pg_stat_activity
-           WHERE backend_type = 'checkpointer' AND wait_event = 'CreateRestartPoint' ;],
-		'1'),
-	'checkpointer is waiting in restart point'
-) or die "Timed out while waiting for checkpointer to run restart point";
+$node_standby->wait_for_injection_point('CreateRestartPoint','checkpointer');
 
 # Check the logs that the restart point has started on standby.  This is
 # optional, but let's be sure.
-- 
2.34.1

Reply via email to