From e86c035242400dfdfed23b00e5459dfef27b8f36 Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Wed, 30 Sep 2020 14:00:05 +0900 Subject: [PATCH] standby promote: in Pg13 and later, promotion overrides paused WAL replay Aborting in this case no longer makes sense, so we apply the checks to PostgreSQL 12 and earlier only. --- doc/repmgr-standby-promote.xml | 11 +++++++---- repmgr-action-standby.c | 7 ++++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/doc/repmgr-standby-promote.xml b/doc/repmgr-standby-promote.xml index 23d78d88..68024aa4 100644 --- a/doc/repmgr-standby-promote.xml +++ b/doc/repmgr-standby-promote.xml @@ -66,10 +66,10 @@ Both values can be defined in repmgr.conf. - + - If WAL replay is paused on the standby, and not all WAL files on the standby have been - replayed, &repmgr; will not attempt to promote it. + In PostgreSQL 12 and earlier, if WAL replay is paused on the standby, and not all + WAL files on the standby have been replayed, &repmgr; will not attempt to promote it. This is because if WAL replay is paused, PostgreSQL itself will not react to a promote command @@ -81,7 +81,10 @@ Note that if the standby is in archive recovery, &repmgr; will not be able to determine if more WAL is pending replay, and will abort the promotion attempt if WAL replay is paused. - + + This restriction does not apply to PostgreSQL 13 and later. + + diff --git a/repmgr-action-standby.c b/repmgr-action-standby.c index 618e7c34..619bb611 100644 --- a/repmgr-action-standby.c +++ b/repmgr-action-standby.c @@ -2333,14 +2333,15 @@ do_standby_promote(void) } /* - * Executing "pg_ctl ... promote" when WAL replay is paused and - * WAL is pending replay will mean the standby will not promote - * until replay is resumed. + * In PostgreSQL 12 and earlier, executing "pg_ctl ... promote" when WAL + * replay is paused and WAL is pending replay will mean the standby will + * not promote until replay is resumed. * * As that could happen at any time outside repmgr's control, we * need to avoid leaving a "ticking timebomb" which might cause * an unexpected status change in the replication cluster. */ + if (PQserverVersion(local_conn) < 130000) { ReplInfo replication_info; bool replay_paused = false;