0006-Use-slot-name-as-application_name-again.patch

application/octet-stream

Filename: 0006-Use-slot-name-as-application_name-again.patch
Type: application/octet-stream
Part: 1
Message: RE: [PATCH] Reuse Workers and Replication Slots during Logical Replication

Patch

Format: format-patch
Series: patch 0006
Subject: Use slot name as application_name again
File+
src/backend/replication/logical/tablesync.c 3 12
From c1c5c8bf5284a397b3a3efdc83be69285e98baa2 Mon Sep 17 00:00:00 2001
From: Hayato Kuroda <kuroda.hayato@fujitsu.com>
Date: Wed, 28 Jun 2023 06:19:34 +0000
Subject: [PATCH 6/6] Use slot name as application_name again

---
 src/backend/replication/logical/tablesync.c | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

diff --git a/src/backend/replication/logical/tablesync.c b/src/backend/replication/logical/tablesync.c
index 4c81a9b4aa..da0264c0b6 100644
--- a/src/backend/replication/logical/tablesync.c
+++ b/src/backend/replication/logical/tablesync.c
@@ -1382,23 +1382,14 @@ LogicalRepSyncTableStart(XLogRecPtr *origin_startpos)
 	 */
 	if (LogRepWorkerWalRcvConn == NULL)
 	{
-		char application_name[NAMEDATALEN];
-
 		/*
-		 * FIXME: set appropriate application_name. Previously, the slot name
-		 * was used becasue the lifetime of the tablesync worker was same as
-		 * that, but now the tablesync worker handles many slots during the
-		 * synchronization so that it is not suitable. So what should be?
-		 * Note that if the tablesync worker starts to reuse the replication
-		 * slot during synchronization, we should use the slot name as
-		 * application_name again.
+		 * Here we use the slot name instead of the subscription name as the
+		 * application_name,
 		 */
-		snprintf(application_name, NAMEDATALEN, "tablesync for %s",
-				 MySubscription->name);
 		LogRepWorkerWalRcvConn =
 			walrcv_connect(MySubscription->conninfo, true,
 						   must_use_password,
-						   application_name, &err);
+						   slotname, &err);
 	}
 
 	if (LogRepWorkerWalRcvConn == NULL)
-- 
2.27.0