From 2fb195418743b0bab89173ef0b42891808eceea2 Mon Sep 17 00:00:00 2001 From: Gaurav Tiwari Date: Wed, 26 Aug 2026 15:35:07 +0100 Subject: [PATCH] Stop repmgrd on manual standbys --- CHANGELOG.md | 1 + lib/active_postgres/components/repmgr.rb | 3 ++- test/repmgr_test.rb | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e7080f..b6a0107 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ and this project follows [Semantic Versioning](https://semver.org/). - Preserve pgBackRest recovery options as one shell-safe argument during remote restore. - Preserve the complete pgBackRest command as the single `bash -lc` command string. - Run component rollback in local Ruby context instead of an SSHKit backend scope. +- Explicitly stop SysV-backed repmgrd before disabling it on manual-failover standbys. ## 0.9.6 - 2026-08-20 diff --git a/lib/active_postgres/components/repmgr.rb b/lib/active_postgres/components/repmgr.rb index b3f7469..43cc101 100644 --- a/lib/active_postgres/components/repmgr.rb +++ b/lib/active_postgres/components/repmgr.rb @@ -1121,7 +1121,8 @@ def update_postgres_configs_on_standby(host, version) def enable_repmgrd_if_configured(host, repmgr_config) if repmgr_config[:auto_failover] == false ssh_executor.execute_on_host(host) do - execute :sudo, 'systemctl', 'disable', '--now', 'repmgrd', raise_on_non_zero_exit: false + execute :sudo, 'systemctl', 'stop', 'repmgrd', raise_on_non_zero_exit: false + execute :sudo, 'systemctl', 'disable', 'repmgrd', raise_on_non_zero_exit: false end return end diff --git a/test/repmgr_test.rb b/test/repmgr_test.rb index 5a2480d..05cdaa3 100644 --- a/test/repmgr_test.rb +++ b/test/repmgr_test.rb @@ -78,7 +78,8 @@ def test_manual_failover_policy_disables_repmgrd component.send(:enable_repmgrd_if_configured, 'standby.example.com', auto_failover: false) assert_equal [ - [[:sudo, 'systemctl', 'disable', '--now', 'repmgrd'], { raise_on_non_zero_exit: false }] + [[:sudo, 'systemctl', 'stop', 'repmgrd'], { raise_on_non_zero_exit: false }], + [[:sudo, 'systemctl', 'disable', 'repmgrd'], { raise_on_non_zero_exit: false }] ], commands end