From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: daff@ptmx.at
Subject: BUG #16288: application_name from client's primary_conninfo not set in pg_stat_replication on master
Date: Mon, 09 Mar 2020 12:24:14 +0000
Message-ID: <16288-67b2b6ad2d4178c6@postgresql.org> (raw)
The following bug has been logged on the website:
Bug reference: 16288
Logged by: Andreas Ntaflos
Email address: daff@ptmx.at
PostgreSQL version: 12.2
Operating system: Ubuntu 18.04
Description:
In a two-node PostgreSQL 12.2 replication scenario, where one node is master
and the other a streaming client, the application_name field in the client's
primary_conninfo setting does not appear to be set correctly in the
pg_stat_replication view on the master. Instead of the application_name
value defined on the client side, the pg_stat_replication view shows the
cluster name in the application_name column.
In our case the replication scenario is managed by Corosync/Pacemaker and
the pgsql resource agent (latest from
https://github.com/ClusterLabs/resource-agents/blob/master/heartbeat/pgsql
which supports the replication/recovery changes introduced in PostgreSQL
12). This currently doesn't work correctly since the resource agent relies
on the information queried from pg_stat_replication to match the Pacemaker
cluster configuration settings, where application_name is supposed to be the
streaming sync client's hostname (i.e. node name).
Recovery settings on the client (db01.example.com) look like this (managed
by the pgsql resource agent):
primary_conninfo = 'host=10.1.33.187 port=5432 user=replication
application_name=db01 keepalives_idle=60 keepalives_interval=5
keepalives_count=5'
restore_command = ''
recovery_target_timeline = 'latest'
primary_slot_name = 'repl_slot_db01'
The pg_stat_replication view on the master (db02.example.com) looks like
this:
postgres=# select usename, application_name, client_addr, client_hostname,
client_port, state, sync_state from pg_stat_replication;
usename | application_name | client_addr | client_hostname |
client_port | state | sync_state
------------------+--------------------+-------------+------------------+-------------+-----------+------------
replication | 12/main | 10.1.33.70 | db01.example.com |
58024 | streaming | async
As you can see, application_name should be "db01" as defined in
primary_conninfo but is "12/main" in pg_stat_replication.
Is this a bug in PostgreSQL 12 or is application_name in primary_conninfo no
longer the proper way to set the application name? For reference, this
replication scenario (also managed by Pacemaker) used to work, and still
works, on PostgreSQL 9.5 through 11. We only encountered this problem on
PostgreSQL 12.2.
Please let me know if there is any more relevant information I can provide.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: noreply@postgresql.org, daff@ptmx.at
Subject: Re: BUG #16288: application_name from client's primary_conninfo not set in pg_stat_replication on master
In-Reply-To: <16288-67b2b6ad2d4178c6@postgresql.org>
References: <16288-67b2b6ad2d4178c6@postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox