tpaexec switchover does not execute /etc/repmgr/16/promote_command.sh
Hi All
As per the documentation https://www.enterprisedb.com/docs/tpa/latest/reference/pgbouncer/ - I can configure repmgr_redirect_pgbouncer: true and expect to see the pgbouncer instance updated when I execute tpaexec switchover ~/clusters/<test_cluster> <standby>
Looking through the code, I'm expecting to see the promote command fire a syntax similar to the following:
/usr/bin/ssh <pgb_instance> "sed -e 's,host=[^ ]* port=[^ ]*,host=<standby> port=5432,' -i /etc/pgbouncer/pgbouncer.databases.ini && pkill -HUP -x pgbouncer" &
I don't see this getting executed however so the pgbouncer instance stays connected to the old primary (now read only) so fails to continue service.
I believe this is due to the fact that the ansible code is firing as follows:
/usr/lib/postgresql/16/bin/repmgr standby switchover --verbose -f /etc/repmgr/16/repmgr.conf --siblings-follow
Based on my understanding the switchover command takes care of a graceful promotion, rather than using the promote command which would then involve the promote_command = '/etc/repmgr/16/promote_command.sh' from the repmgr.comf file
Needless to say, no switching of the pgbouncer DB connection takes place.
https://www.repmgr.org/docs/current/repmgr-standby-promote.html https://www.repmgr.org/docs/current/repmgr-standby-switchover.html
https://www.enterprisedb.com/docs/tpa/latest/reference/pgbouncer/ - detail https://www.enterprisedb.com/docs/tpa/latest/INSTALL-repo/ - install location and version
# TPAexec v23.36.0-10-g7eeb2926 (branch: main)
tpaexec=/home/tonyd/tpa/bin/tpaexec
TPA_DIR=/home/tonyd/tpa
PYTHON=/home/tonyd/tpa/tpa-venv/bin/python3 (v3.12.3, venv)
TPA_VENV=/home/tonyd/tpa/tpa-venv
ANSIBLE=/home/tonyd/tpa/tpa-venv/bin/ansible (v2.16.14)
On branch main
Your branch is up to date with 'origin/main'.
This is based on an M1 architecture as per:
tpaexec configure ~/clusters/test01 --architecture M1 \
--platform bare \
--postgresql 16 \
--failover-manager repmgr \
--hostnames-from ~/clusters/servers.txt \
--keyring-backend legacy
Hello,
thank you for opening an issue, your understanding seems to line up with mine, /usr/lib/postgresql/16/bin/repmgr standby switchover --verbose -f /etc/repmgr/16/repmgr.conf --siblings-follow won't call the promote_command.
those are only used by repmgrd in failover scenario where the node that was primary shouldn't be set as a replica since it is in a failed state.
It makes sense for the switchover command in tpaexec to help with the pgbouncer redirection which is not the case at the moment.
I'm opening a ticket on our internal tracking system.
This has been Fixed in tpaexec 23.38.0 see release notes: TPA will now redirect PgBouncer to the new primary in M1 repmgr clusters during switchover.