summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Eisentraut2019-02-08 07:17:21 +0000
committerPeter Eisentraut2019-02-27 09:59:25 +0000
commit6ae578a91e653ce3f4cba8cab96ce41e0cc7103f (patch)
tree6b72d6f6e587f82ebbe2dcf4aecb39181146a9b7
parent414a9d3cf34c7aff1c63533df4c40ebb63bd0840 (diff)
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 <[email protected]> Discussion: https://www.postgresql.org/message-id/flat/[email protected]
-rw-r--r--doc/src/sgml/config.sgml14
-rw-r--r--src/backend/replication/walreceiver.c2
2 files changed, 12 insertions, 4 deletions
diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index 8bd57f376b..1c3b7affa9 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -3659,7 +3659,8 @@ restore_command = 'copy "C:\\server\\archivedir\\%f" "%p"' # Windows
<varname>application_name</varname> setting of the standby, as set in the
standby's connection information. In case of a physical replication
standby, this should be set in the <varname>primary_conninfo</varname>
- setting; the default is <literal>walreceiver</literal>.
+ setting; the default is the setting of <xref linkend="guc-cluster-name"/>
+ if set, else <literal>walreceiver</literal>.
For logical replication, this can be set in the connection
information of the subscription, and it defaults to the
subscription name. For other replication stream consumers,
@@ -6560,8 +6561,15 @@ COPY postgres_log FROM '/full/path/to/logfile.csv' WITH csv;
</term>
<listitem>
<para>
- Sets the cluster name that appears in the process title for all
- server processes in this cluster. The name can be any string of less
+ Sets a name that identifies this database cluster (instance) for
+ various purposes. The cluster name appears in the process title for
+ all server processes in this cluster. Moreover, it is the default
+ application name for a standby connection (see <xref
+ linkend="guc-synchronous-standby-names"/>.)
+ </para>
+
+ <para>
+ The name can be any string of less
than <symbol>NAMEDATALEN</symbol> characters (64 characters in a standard
build). Only printable ASCII characters may be used in the
<varname>cluster_name</varname> value. Other characters will be
diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c
index 2e90944ad5..9eaaa8ff50 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -293,7 +293,7 @@ WalReceiverMain(void)
/* Establish the connection to the primary for XLOG streaming */
EnableWalRcvImmediateExit();
- wrconn = walrcv_connect(conninfo, false, "walreceiver", &err);
+ wrconn = walrcv_connect(conninfo, false, cluster_name[0] ? cluster_name : "walreceiver", &err);
if (!wrconn)
ereport(ERROR,
(errmsg("could not connect to the primary server: %s", err)));