From ae7940362d10df42dcfa78bd31c5117a67ab088a Mon Sep 17 00:00:00 2001
From: Zhijie Hou <houzj.fnst@fujitsu.com>
Date: Thu, 11 Sep 2025 16:29:49 +0800
Subject: [PATCH v1] Fix unstable test in 6456c6e

The test introduced in commit 6456c6e anticipates a backend to execute COMMIT
PREPARED and enter the injection point 'commit-after-delay-checkpoint' within
the commit critical section. Consequently, the apply worker on the subscriber
should wait for this transaction to finish. However, as the test does not ensure
the injection point is triggered, there exists a window where the apply
worker might proceed prematurely during the execution of COMMIT PREPARED. This
commit addresses the issue by ensuring the wait event for the injection point is
triggered before conducting further tests.
---
 src/test/subscription/t/035_conflicts.pl | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/test/subscription/t/035_conflicts.pl b/src/test/subscription/t/035_conflicts.pl
index db0d5b464e8..880551fc69d 100644
--- a/src/test/subscription/t/035_conflicts.pl
+++ b/src/test/subscription/t/035_conflicts.pl
@@ -475,6 +475,9 @@ if ($injection_points_supported != 0)
 		}
 	);
 
+	# Wait until the backend enters the injection point
+	$node_B->wait_for_event('client backend', 'commit-after-delay-checkpoint');
+
 	# Confirm the update is suspended
 	$result =
 	  $node_B->safe_psql('postgres', 'SELECT * FROM tab WHERE a = 1');
-- 
2.51.0.windows.1

