From 37c345310f38951a22484dbfeb31fdc795e12c44 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter_e@gmx.net>
Date: Wed, 17 May 2017 22:24:32 -0400
Subject: [PATCH] Improve logical replication worker log messages

---
 src/backend/replication/logical/launcher.c  | 2 +-
 src/backend/replication/logical/tablesync.c | 5 ++++-
 src/backend/replication/logical/worker.c    | 4 ++--
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/backend/replication/logical/launcher.c b/src/backend/replication/logical/launcher.c
index 4e2c350dc7..b956052014 100644
--- a/src/backend/replication/logical/launcher.c
+++ b/src/backend/replication/logical/launcher.c
@@ -260,7 +260,7 @@ logicalrep_worker_launch(Oid dbid, Oid subid, const char *subname, Oid userid,
 	int			nsyncworkers;
 	TimestampTz now;
 
-	ereport(LOG,
+	ereport(DEBUG1,
 	   (errmsg("starting logical replication worker for subscription \"%s\"",
 			   subname)));
 
diff --git a/src/backend/replication/logical/tablesync.c b/src/backend/replication/logical/tablesync.c
index 1e3753b8fe..d69fc7086d 100644
--- a/src/backend/replication/logical/tablesync.c
+++ b/src/backend/replication/logical/tablesync.c
@@ -133,8 +133,11 @@ finish_sync_worker(void)
 	/* Find the main apply worker and signal it. */
 	logicalrep_worker_wakeup(MyLogicalRepWorker->subid, InvalidOid);
 
+	StartTransactionCommand();
 	ereport(LOG,
-			(errmsg("logical replication synchronization worker finished processing")));
+			(errmsg("logical replication table synchronization worker for subscription \"%s\", table \"%s\" has finished",
+					MySubscription->name, get_rel_name(MyLogicalRepWorker->relid))));
+	CommitTransactionCommand();
 
 	/* Stop gracefully */
 	walrcv_disconnect(wrconn);
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c
index 7d1787db5c..11cbcf18e5 100644
--- a/src/backend/replication/logical/worker.c
+++ b/src/backend/replication/logical/worker.c
@@ -1516,10 +1516,10 @@ ApplyWorkerMain(Datum main_arg)
 								  (Datum) 0);
 
 	if (am_tablesync_worker())
-		elog(LOG, "logical replication sync for subscription %s, table %s started",
+		elog(LOG, "logical replication table synchronization worker for subscription \"%s\", table \"%s\" has started",
 			 MySubscription->name, get_rel_name(MyLogicalRepWorker->relid));
 	else
-		elog(LOG, "logical replication apply for subscription %s started",
+		elog(LOG, "logical replication apply worker for subscription \"%s\" has started",
 			 MySubscription->name);
 
 	CommitTransactionCommand();
-- 
2.13.0

