repmgr
repmgr copied to clipboard
Rempgrd doesn't run when the database is stopped before repmgrd on standby
Hello,
I have noticed an issue with repmgrd shutdown sequence. When repmgrd lost a connection to the local standby database it enters to the "degraded monitoring for the local node" and this node is marked as inactive in repmgr.nodes table. After that the repmgrd is stopped on this node with a init script.
Now rempgrd refuses to start because failover option is set to automatic. I had to run repmgr standby register --force
to reregister this node. Is this expected behavior or a bug?
`[2021-02-22 18:32:27] [DETAIL] attempted to connect using: user=repmgr connect_timeout=2 dbname=repmgr host=sql-2 port=5432 fallback_application_name=repmgr options=-csearch_path= [2021-02-22 18:32:27] [WARNING] reconnection to node "sql-2" (ID: 2) failed [2021-02-22 18:32:27] [NOTICE] unable to connect to local node "sql-2" (ID: 2), marking inactive [2021-02-22 18:32:27] [INFO] entering degraded monitoring for the local node [2021-02-22 18:32:27] [ERROR] _get_node_record(): unable to execute query
[2021-02-22 18:48:34] [DEBUG] node id is 2, upstream node id is 1 [2021-02-22 18:48:34] [ERROR] this node is marked as inactive and cannot be used as a failover target [2021-02-22 18:48:34] [HINT] Check that "repmgr (primary|standby) register" was executed for this node [2021-02-22 18:48:34] [INFO] repmgrd terminating... `
I think you have to start the database first. Only then you can start repmgrd or register the standby.
Problem is with stopping services. When PostgreSQL server is stopped a few seconds before repmgrd, this node becomes marked as inactive and repmgrd newer starts again. A repmgrd is started when PostgreSQL is already running.
yes, it seems one has to reregister the standby in this case. But when you reboot the server, repmgrd ist always stopped before Postgres
In most cases probably yes. Init script supplied with a Debian package has postgresql as Required-Stop dependency. So init system will not stop postgresql before repmgrd. But there is a chance that PostgreSQL is stopped manually before reboot.