Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 6ae578a

Browse files
committed
Set fallback_application_name for a walreceiver to cluster_name
By default, the fallback_application_name for a physical walreceiver is "walreceiver". This means that multiple standbys cannot be distinguished easily on a primary, for example in pg_stat_activity or synchronous_standby_names. If cluster_name is set, use that for fallback_application_name in the walreceiver. (If it's not set, it remains "walreceiver".) If someone set cluster_name to identify their instance, we might as well use that by default to identify the node remotely as well. It's still possible to specify another application_name in primary_conninfo explicitly. Reviewed-by: Euler Taveira <euler@timbira.com.br> Discussion: https://www.postgresql.org/message-id/flat/1257eaee-4874-e791-e83a-46720c72cac7@2ndquadrant.com
1 parent 414a9d3 commit 6ae578a

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

doc/src/sgml/config.sgml

+11-3
Original file line numberDiff line numberDiff line change
@@ -3659,7 +3659,8 @@ restore_command = 'copy "C:\\server\\archivedir\\%f" "%p"' # Windows
36593659
<varname>application_name</varname> setting of the standby, as set in the
36603660
standby's connection information. In case of a physical replication
36613661
standby, this should be set in the <varname>primary_conninfo</varname>
3662-
setting; the default is <literal>walreceiver</literal>.
3662+
setting; the default is the setting of <xref linkend="guc-cluster-name"/>
3663+
if set, else <literal>walreceiver</literal>.
36633664
For logical replication, this can be set in the connection
36643665
information of the subscription, and it defaults to the
36653666
subscription name. For other replication stream consumers,
@@ -6560,8 +6561,15 @@ COPY postgres_log FROM '/full/path/to/logfile.csv' WITH csv;
65606561
</term>
65616562
<listitem>
65626563
<para>
6563-
Sets the cluster name that appears in the process title for all
6564-
server processes in this cluster. The name can be any string of less
6564+
Sets a name that identifies this database cluster (instance) for
6565+
various purposes. The cluster name appears in the process title for
6566+
all server processes in this cluster. Moreover, it is the default
6567+
application name for a standby connection (see <xref
6568+
linkend="guc-synchronous-standby-names"/>.)
6569+
</para>
6570+
6571+
<para>
6572+
The name can be any string of less
65656573
than <symbol>NAMEDATALEN</symbol> characters (64 characters in a standard
65666574
build). Only printable ASCII characters may be used in the
65676575
<varname>cluster_name</varname> value. Other characters will be

src/backend/replication/walreceiver.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ WalReceiverMain(void)
293293

294294
/* Establish the connection to the primary for XLOG streaming */
295295
EnableWalRcvImmediateExit();
296-
wrconn = walrcv_connect(conninfo, false, "walreceiver", &err);
296+
wrconn = walrcv_connect(conninfo, false, cluster_name[0] ? cluster_name : "walreceiver", &err);
297297
if (!wrconn)
298298
ereport(ERROR,
299299
(errmsg("could not connect to the primary server: %s", err)));

0 commit comments

Comments
 (0)