From 0bc0a2837854bee87113f733668875054876ef2a Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Fri, 6 Mar 2020 13:20:44 +0900 Subject: [PATCH] standby promote: enable "service_promote_command" in PostgreSQL 12 This enables the promote command generated internally by repmgr to be overridden if desired, in the same way as for PostgreSQL 11 and earlier. --- HISTORY | 3 ++- doc/appendix-release-notes.xml | 6 ++++++ doc/repmgr-standby-promote.xml | 17 +++++++++++++++++ repmgr-action-standby.c | 6 +++++- 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/HISTORY b/HISTORY index 9f2897e7..0951eb7c 100644 --- a/HISTORY +++ b/HISTORY @@ -1,4 +1,4 @@ -5.1 2019-??-?? +5.1 2020-??-?? repmgr: remove BDR 2.x support repmgr: don't query upstream's data directory (Ian) repmgr: rename --recovery-conf-only to --replication-conf-only (Ian) @@ -14,6 +14,7 @@ repmgr: consolidate replication connection code (Ian) repmgr: check permissions for "pg_promote()" and fall back to pg_ctl if necessary (Ian) + repmgr: enable "service_promote_command" in PostgreSQL 12 (Ian) 5.0 2019-10-15 general: add PostgreSQL 12 support (Ian) diff --git a/doc/appendix-release-notes.xml b/doc/appendix-release-notes.xml index 1eefcdeb..e326985b 100644 --- a/doc/appendix-release-notes.xml +++ b/doc/appendix-release-notes.xml @@ -97,6 +97,12 @@ + + + repmgr standby promote: + in PostgreSQL 12 and later, use service_promote_command if set. + + diff --git a/doc/repmgr-standby-promote.xml b/doc/repmgr-standby-promote.xml index 4a26a3a2..ceebd356 100644 --- a/doc/repmgr-standby-promote.xml +++ b/doc/repmgr-standby-promote.xml @@ -195,6 +195,23 @@ + + + service_promote_command + with "repmgr standby promote " + + + service_promote_command: + a command which will be executed instead of pg_ctl promote + or (in PostgreSQL 12 and later) pg_promote(). + + + This is intended for systems which provide a package-level promote command, + such as Debian's pg_ctlcluster, to promote the + PostgreSQL from standby to primary. + + + diff --git a/repmgr-action-standby.c b/repmgr-action-standby.c index 201ba433..10a15ec3 100644 --- a/repmgr-action-standby.c +++ b/repmgr-action-standby.c @@ -2487,7 +2487,11 @@ _do_standby_promote_internal(PGconn *conn) { use_pg_promote = true; - if (can_execute_pg_promote(conn) == false) + if (config_file_options.service_promote_command[0] != '\0') + { + use_pg_promote = false; + } + else if (can_execute_pg_promote(conn) == false) { use_pg_promote = false; log_info(_("user \"%s\" does not have permission to execute \"pg_promote()\", falling back to \"pg_ctl promote\""),