From 15f907b4a980bdad80fae86146b143721854f500 Mon Sep 17 00:00:00 2001
From: Zhijie Hou <houzj.fnst@fujitsu.com>
Date: Thu, 24 Jul 2025 10:44:12 +0800
Subject: [PATCH] Fix Cfbot failure

The test failed to enable the retain_dead_tuples option for a disabled
subscription failed due to the apply worker for that subscription still running.
To resolve this issue, ensure the apply worker has stopped after disabling the
subscription.
---
 src/test/subscription/t/035_conflicts.pl | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/test/subscription/t/035_conflicts.pl b/src/test/subscription/t/035_conflicts.pl
index 7458d7fba7e..976d53a870e 100644
--- a/src/test/subscription/t/035_conflicts.pl
+++ b/src/test/subscription/t/035_conflicts.pl
@@ -228,6 +228,11 @@ ok( $stderr =~
 # Disable the subscription
 $node_A->psql('postgres', "ALTER SUBSCRIPTION $subname_AB DISABLE;");
 
+# Wait for the apply worker to stop
+$node_A->poll_query_until('postgres',
+	"SELECT count(*) = 0 FROM pg_stat_activity WHERE backend_type = 'logical replication apply worker'"
+);
+
 # Enable retain_dead_tuples for disabled subscription
 ($cmdret, $stdout, $stderr) = $node_A->psql('postgres',
 	"ALTER SUBSCRIPTION $subname_AB SET (retain_dead_tuples = true);");
@@ -278,6 +283,11 @@ is($result, qq(1|1
 # Disable the logical replication from node B to node A
 $node_A->safe_psql('postgres', "ALTER SUBSCRIPTION $subname_AB DISABLE");
 
+# Wait for the apply worker to stop
+$node_A->poll_query_until('postgres',
+	"SELECT count(*) = 0 FROM pg_stat_activity WHERE backend_type = 'logical replication apply worker'"
+);
+
 $node_B->safe_psql('postgres', "UPDATE tab SET b = 3 WHERE a = 1;");
 $node_A->safe_psql('postgres', "DELETE FROM tab WHERE a = 1;");
 
-- 
2.50.1.windows.1

