Hi,

When walsender process is evoked for logical replication, walsender is connected to a database of the subscriber. Naturally, ones would want the name of the connected database to show in the entry of ps command for walsender. In detail, running ps aux during the logical replication shows results like the following:
postgres=# \! ps aux | grep postgres;
...
ACTC-I\+ 14575 0.0 0.0 298620 14228 ? Ss 18:22 0:00 postgres: walsender ACTC-I\nakamorit [local] S

However, since walsender is connected to a database of the subscriber in logical replication, it should show the database name, as in the following:
postgres=# \! ps aux | grep postgres
...
ACTC-I\+ 15627 0.0 0.0 298624 13936 ? Ss 15:45 0:00 postgres: walsender ACTC-I\nakamorit postgres

Showing the database name should not apply in streaming replication though since walsender process is not connected to any specific database.

The attached patch adds the name of the connected database to the ps entry of walsender in logical replication, and not in streaming replication.

Thoughts?

Tatsuhiro Nakamori
diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c
index 383bc4776e..6cbb69767c 100644
--- a/src/backend/postmaster/postmaster.c
+++ b/src/backend/postmaster/postmaster.c
@@ -4187,7 +4187,9 @@ BackendStartup(Port *port)
 	if (pid == 0)				/* child */
 	{
 		free(bn);
-
+		printf("fork child process\n");
+		printf("	am_walsender: %d\n", am_walsender);
+		printf("	am_db_walsender: %d\n", am_db_walsender);
 		/* Detangle from postmaster */
 		InitPostmasterChild();
 
@@ -4451,7 +4453,7 @@ BackendInitialize(Port *port)
 	if (am_walsender)
 		appendStringInfo(&ps_data, "%s ", GetBackendTypeDesc(B_WAL_SENDER));
 	appendStringInfo(&ps_data, "%s ", port->user_name);
-	if (!am_walsender)
+	if (!am_walsender || am_db_walsender)
 		appendStringInfo(&ps_data, "%s ", port->database_name);
 	appendStringInfoString(&ps_data, port->remote_host);
 	if (port->remote_port[0] != '\0')

Reply via email to