"Warning: No existing cluster is suitable as a default target" from repmgr commands with multiple instances of PostgreSQL
Opened this issue · 3 comments
I set up two instances ("clusters") of PostgreSQL 14.1 on an Unbuntu 18.04 machine with repmgr (v5.3) for both. I find that when I run any repmgr command it prints a warning:
Warning: No existing cluster is suitable as a default target. Please see man pg_wrapper(1) how to specify one.
Given that I'm already specifying a hostname and port in the conninfo string I would expect no such warning without any workarounds - the cluster is already unambiguous.
As the referenced man page says, it's possible to set the PGCLUSTER environment variable to avoid this:
sudo -iu postgres
postgres@ansible-test:~$ PGCLUSTER=14/behavior repmgr -f /etc/postgresql/14/requestlog/repmgr.conf cluster show
(no warning!)
It's a hassle to make this work through sudo, however, and this workaround shouldn't really be needed.
Complete output with -LDEBUG:
# sudo -u postgres repmgr -f /etc/postgresql/14/requestlog/repmgr.conf cluster show -LDEBUG --verbose
Warning: No existing cluster is suitable as a default target. Please see man pg_wrapper(1) how to specify one.
NOTICE: using provided configuration file "/etc/postgresql/14/requestlog/repmgr.conf"
INFO: connecting to database
DEBUG: connecting to: "user=repmgr_dev dbname=repmgr host=ansible-test port=5433 connect_timeout=2 fallback_application_name=repmgr options=-csearch_path="
DEBUG: set_config():
SET synchronous_commit TO 'local'
DEBUG: get_all_node_records_with_upstream():
SELECT n.node_id, n.type, n.upstream_node_id, n.node_name, n.conninfo, n.repluser, n.slot_name, n.location, n.priority, n.active, n.config_file, un.node_name AS upstream_node_name, NULL AS attached FROM repmgr.nodes n LEFT JOIN repmgr.nodes un ON un.node_id = n.upstream_node_id ORDER BY n.node_id
DEBUG: clear_node_info_list() - closing open connections
DEBUG: clear_node_info_list() - unlinking
DEBUG: connecting to: "user=repmgr_dev dbname=repmgr host=ansible-test port=5433 connect_timeout=2 fallback_application_name=repmgr options=-csearch_path="
DEBUG: set_config():
SET synchronous_commit TO 'local'
DEBUG: get_recovery_type(): SELECT pg_catalog.pg_is_in_recovery()
DEBUG: get_node_record():
SELECT n.node_id, n.type, n.upstream_node_id, n.node_name, n.conninfo, n.repluser, n.slot_name, n.location, n.priority, n.active, n.config_file, un.node_name AS upstream_node_name, NULL AS attached FROM repmgr.nodes n LEFT JOIN repmgr.nodes un ON un.node_id = n.upstream_node_id WHERE n.node_id = 1
ID | Name | Role | Status | Upstream | Location | Priority | Timeline | Connection string
----+--------------+---------+-----------+----------+----------+----------+----------+-----------------------------------------------------------
1 | ansible-test | primary | * running | | default | 100 | 1 | host=ansible-test port=5433 user=repmgr_dev dbname=repmgr
DEBUG: clear_node_info_list() - closing open connections
DEBUG: clear_node_info_list() - unlinking
repmgr.conf has this
node_id = 1
node_name = 'ansible-test'
conninfo = 'host=ansible-test port=5433 user=repmgr_dev dbname=repmgr'
replication_user = 'repmgr_streaming_dev'
data_directory = '/pgdata/requestlog-pg14'
The warning you mention:
# sudo -u postgres repmgr -f /etc/postgresql/14/requestlog/repmgr.conf cluster show -LDEBUG --verbose
Warning: No existing cluster is suitable as a default target. Please see man pg_wrapper(1) how to specify one.
is not generated by repmgr
; it appears to be related to the Debian packaging's PostgreSQL wrapper. Maybe the Debian packagers can provided further assistance.
I understand that the warning is generated by pg_wrapper, but without knowing how repmgr is using pg_wrapper it's impossible to say which of them is doing something unexpected.
One behavior that's definitely unexpected, and almost certainly due to repmgr, is that it prints the warning even for operations that don't require connecting to any cluster, e.g.
$ repmgr --help
Warning: No existing cluster is suitable as a default target. Please see man pg_wrapper(1) how to specify one.
repmgr: replication management tool for PostgreSQL
Usage:
...
With cluster crosscheck
this is happening even if I do set PGCLUSTER on the command line. PostgreSQL 15.0 and repmgr 5.3.3.
postgres:~$ LC_ALL=C PGCLUSTER=15/MY_INSTANCE repmgr -f /etc/postgresql/15/MY_INSTANCE/repmgr.conf -v cluster crosscheck
NOTICE: using provided configuration file "/etc/postgresql/15/MY_INSTANCE/repmgr.conf"
INFO: connecting to database
Warning: No existing cluster is suitable as a default target. Please see man pg_wrapper(1) how to specify one.
Warning: No existing cluster is suitable as a default target. Please see man pg_wrapper(1) how to specify one.
Name | ID | 1 | 2
-----------------------+----+---+---
PRIMARY_HOSTNAME | 1 | * | *
STANDBY_HOSTNAME | 2 | * | *
With -L DEBUG
:
postgres:~$ LC_ALL=C PGCLUSTER=15/MY_INSTANCE repmgr -f /etc/postgresql/15/MY_INSTANCE/repmgr.conf -v -LDEBUG cluster crosscheck
NOTICE: using provided configuration file "/etc/postgresql/15/MY_INSTANCE/repmgr.conf"
INFO: connecting to database
DEBUG: connecting to: "user=repmgr_dev dbname=repmgr host=PRIMARY_HOSTNAME port=5434 sslmode=require connect_timeout=2 fallback_application_name=repmgr options=-csearch_path="
DEBUG: set_config():
SET synchronous_commit TO 'local'
DEBUG: get_all_node_records():
SELECT n.node_id, n.type, n.upstream_node_id, n.node_name, n.conninfo, n.repluser, n.slot_name, n.location, n.priority, n.active, n.config_file, '' AS upstream_node_name, NULL AS attached FROM repmgr.nodes n ORDER BY n.node_id
DEBUG: clear_node_info_list() - closing open connections
DEBUG: clear_node_info_list() - unlinking
DEBUG: executing:
repmgr -f /etc/postgresql/15/MY_INSTANCE/repmgr.conf -L DEBUG cluster matrix --csv --terse 2>/tmp/repmgr_command.LWu9QV
DEBUG: result of command was 0 (0)
DEBUG: local_command(): output returned was:
1,1,0
1,2,0
2,1,0
2,2,0
INFO: connecting to database
DEBUG: connecting to: "user=repmgr_dev dbname=repmgr host=PRIMARY_HOSTNAME port=5434 sslmode=require connect_timeout=2 fallback_application_name=repmgr options=-csearch_path="
DEBUG: connecting to: "user=repmgr_dev dbname=repmgr host=PRIMARY_HOSTNAME port=5434 connect_timeout=2 fallback_application_name=repmgr options=-csearch_path="
DEBUG: connecting to: "user=repmgr_dev dbname=repmgr host=STANDBY_HOSTNAME port=5434 connect_timeout=2 fallback_application_name=repmgr options=-csearch_path="
DEBUG: remote_command():
ssh -o Batchmode=yes -q -o BatchMode=yes -o ConnectTimeout=5 STANDBY_HOSTNAME "repmgr -f /etc/postgresql/15/MY_INSTANCE/repmgr.conf -L DEBUG cluster show --csv --terse"
Warning: No existing cluster is suitable as a default target. Please see man pg_wrapper(1) how to specify one.
DEBUG: connecting to: "user=repmgr_dev dbname=repmgr host=STANDBY_HOSTNAME port=5434 sslmode=require connect_timeout=2 fallback_application_name=repmgr options=-csearch_path="
DEBUG: connecting to: "user=repmgr_dev dbname=repmgr host=PRIMARY_HOSTNAME port=5434 connect_timeout=2 fallback_application_name=repmgr options=-csearch_path="
DEBUG: connecting to: "user=repmgr_dev dbname=repmgr host=STANDBY_HOSTNAME port=5434 connect_timeout=2 fallback_application_name=repmgr options=-csearch_path="
DEBUG: connecting to: "user=repmgr_dev dbname=repmgr host=PRIMARY_HOSTNAME port=5434 connect_timeout=2 fallback_application_name=repmgr options=-csearch_path="
DEBUG: build_cluster_crosscheck(): executing
"repmgr -f /etc/postgresql/15/MY_INSTANCE/repmgr.conf -L DEBUG cluster matrix --csv --terse"
DEBUG: remote_command():
ssh -o Batchmode=yes -q -o BatchMode=yes -o ConnectTimeout=5 STANDBY_HOSTNAME "repmgr -f /etc/postgresql/15/MY_INSTANCE/repmgr.conf -L DEBUG cluster matrix --csv --terse"
Warning: No existing cluster is suitable as a default target. Please see man pg_wrapper(1) how to specify one.
INFO: connecting to database
DEBUG: connecting to: "user=repmgr_dev dbname=repmgr host=STANDBY_HOSTNAME port=5434 sslmode=require connect_timeout=2 fallback_application_name=repmgr options=-csearch_path="
DEBUG: connecting to: "user=repmgr_dev dbname=repmgr host=PRIMARY_HOSTNAME port=5434 connect_timeout=2 fallback_application_name=repmgr options=-csearch_path="
DEBUG: remote_command():
ssh -o Batchmode=yes -q -o BatchMode=yes -o ConnectTimeout=5 PRIMARY_HOSTNAME "repmgr -f /etc/postgresql/15/MY_INSTANCE/repmgr.conf -L DEBUG cluster show --csv --terse"
Warning: No existing cluster is suitable as a default target. Please see man pg_wrapper(1) how to specify one.
DEBUG: connecting to: "user=repmgr_dev dbname=repmgr host=PRIMARY_HOSTNAME port=5434 sslmode=require connect_timeout=2 fallback_application_name=repmgr options=-csearch_path="
DEBUG: connecting to: "user=repmgr_dev dbname=repmgr host=PRIMARY_HOSTNAME port=5434 connect_timeout=2 fallback_application_name=repmgr options=-csearch_path="
DEBUG: connecting to: "user=repmgr_dev dbname=repmgr host=STANDBY_HOSTNAME port=5434 connect_timeout=2 fallback_application_name=repmgr options=-csearch_path="
DEBUG: connecting to: "user=repmgr_dev dbname=repmgr host=PRIMARY_HOSTNAME port=5434 connect_timeout=2 fallback_application_name=repmgr options=-csearch_path="
DEBUG: connecting to: "user=repmgr_dev dbname=repmgr host=STANDBY_HOSTNAME port=5434 connect_timeout=2 fallback_application_name=repmgr options=-csearch_path="
DEBUG: remote_command(): output returned was:
1,1,0
1,2,0
2,1,0
2,2,0
DEBUG: clear_node_info_list() - closing open connections
DEBUG: clear_node_info_list() - unlinking
Name | ID | 1 | 2
-----------------------+----+---+---
PRIMARY_HOSTNAME | 1 | * | *
STANDBY_HOSTNAME | 2 | * | *