From 2d73fc12ff3c81ce2cba8bdcbc404ea8b96535e6 Mon Sep 17 00:00:00 2001
From: Zhijie Hou <houzj.fnst@fujitsu.com>
Date: Tue, 2 Sep 2025 13:01:36 +0800
Subject: [PATCH v2 2/2] Wakeup launcher on subscription creation to create the
 conflict detection slot

When a disabled subscription is created with retain_dead_tuples set to true, the
launcher is not woken up immediately, which may lead to delays in creating the
conflict detection slot and cause user confusion. This commit ensures that the
subscription creation command triggers an immediate launcher wakeup.
---
 src/backend/commands/subscriptioncmds.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/backend/commands/subscriptioncmds.c b/src/backend/commands/subscriptioncmds.c
index 82cf65fae73..faec92b8078 100644
--- a/src/backend/commands/subscriptioncmds.c
+++ b/src/backend/commands/subscriptioncmds.c
@@ -854,7 +854,12 @@ CreateSubscription(ParseState *pstate, CreateSubscriptionStmt *stmt,
 
 	pgstat_create_subscription(subid);
 
-	if (opts.enabled)
+	/*
+	 * Notify the launcher to start the apply worker if the subscription is
+	 * enabled or to create the conflict detection slot if retain_dead_tuples is
+	 * enabled.
+	 */
+	if (opts.enabled || opts.retaindeadtuples)
 		ApplyLauncherWakeupAtCommit();
 
 	ObjectAddressSet(myself, SubscriptionRelationId, subid);
-- 
2.51.0.windows.1

