Обсуждение: show primary_conninfo unchanged after promotion?

Поиск
Список
Период
Сортировка

show primary_conninfo unchanged after promotion?

От
Wiwwo Staff
Дата:
Hi!
i might be doing something wrong, but I cannot see what...

Server is 14.3 (Debian 14.3-1.pgdg110+1)
(at the time of writing, in Dockerfile FROM postgres:14)

I have a 3 node cluster, starting with pg_red (172.26.0.2) as primary.
I promote pg_green (172.26.0.4) as new primary, all other aligned.

Now, on pg_green (172.26.0.4):

=# select inet_server_addr();
 inet_server_addr
------------------
 172.26.0.4

=# select pg_is_in_recovery();
 pg_is_in_recovery
-------------------
 f

=# select * from pg_stat_replication; (CUT)
 pid | usesysid | usename | application_name | client_addr
-----+----------+---------+------------------+-------------
 486 |   16,384 | rep     | walreceiver      | 172.21.0.2  
 625 |   16,384 | rep     | walreceiver      | 172.21.0.4  

But, if I execute show primary_conninfo, i get
=# show primary_conninfo ;
                                                                      primary_conninfo
------------------------------------------------------------------------------------------------------------------------------------------------------------
 user=rep passfile='/.pgpass' channel_binding=prefer host=pg_red port=5432 sslmode=prefer sslcompression=0 sslsni=1 ssl_min_protocol_version=TLSv1.2 g.
.ssencmode=prefer krbsrvname=postgres target_session_attrs=any

which says primary is pg_red, which is the old primary.

What is that I am doing wrong?!?
Tnx!


Re: show primary_conninfo unchanged after promotion?

От
Ian Lawrence Barwick
Дата:
2022年5月18日(水) 23:07 Wiwwo Staff <wiwwo@wiwwo.com>:
>
> Hi!
> i might be doing something wrong, but I cannot see what...
>
> Server is 14.3 (Debian 14.3-1.pgdg110+1)
> (at the time of writing, in Dockerfile FROM postgres:14)
>
> I have a 3 node cluster, starting with pg_red (172.26.0.2) as primary.
> I promote pg_green (172.26.0.4) as new primary, all other aligned.
>
> Now, on pg_green (172.26.0.4):
>
> =# select inet_server_addr();
>  inet_server_addr
> ------------------
>  172.26.0.4
>
> =# select pg_is_in_recovery();
>  pg_is_in_recovery
> -------------------
>  f
>
> =# select * from pg_stat_replication; (CUT)
>  pid | usesysid | usename | application_name | client_addr
> -----+----------+---------+------------------+-------------
>  486 |   16,384 | rep     | walreceiver      | 172.21.0.2
>  625 |   16,384 | rep     | walreceiver      | 172.21.0.4
>
> But, if I execute show primary_conninfo, i get
> =# show primary_conninfo ;
>                                                                       primary_conninfo
>
------------------------------------------------------------------------------------------------------------------------------------------------------------
>  user=rep passfile='/.pgpass' channel_binding=prefer host=pg_red port=5432 sslmode=prefer sslcompression=0 sslsni=1
ssl_min_protocol_version=TLSv1.2g. 
> .ssencmode=prefer krbsrvname=postgres target_session_attrs=any
>
> which says primary is pg_red, which is the old primary.

You're not doing anything wrong, it's just that the value of
primary_conninfo is left untouched after promotion. It is however
ignored if the server is a primary; see:

  https://www.postgresql.org/docs/current/runtime-config-replication.html#GUC-PRIMARY-CONNINFO

which states: "This setting has no effect if the server is not in standby mode."

Regards

Ian Barwick

--
EnterpriseDB: https://www.enterprisedb.com