From 743e0e5480e4110a9314e9b69b8131f56952790b Mon Sep 17 00:00:00 2001 From: zhouhj43183 Date: Wed, 11 May 2022 13:35:29 +0900 Subject: [PATCH] repmgrd: ensure witness node marked active Previously, if the witness node's PostgreSQL was unreachable, it would be marked as "inactive" on the primary, and under some circumstances would not be corrected to "active" once the witness node's PostgreSQL came back. PR #754; some modifications by Ian Barwick. --- HISTORY | 1 + doc/appendix-release-notes.xml | 7 +++++++ repmgrd-physical.c | 12 ++++++++++++ 3 files changed, 20 insertions(+) diff --git a/HISTORY b/HISTORY index ad2b3bd6..03cc84f5 100644 --- a/HISTORY +++ b/HISTORY @@ -1,6 +1,7 @@ 5.3.2 2022-??-?? standby clone: don't error out if unable to determine cluster size (Ian) node check: fix --downstream --nagios output; GitHub #749 (Ian) + repmgrd: ensure witness node marked active (hslightdb) 5.3.1 2022-02-15 repmgrd: fixes for potential connection leaks (hslightdb) diff --git a/doc/appendix-release-notes.xml b/doc/appendix-release-notes.xml index b4409e11..a79f4c23 100644 --- a/doc/appendix-release-notes.xml +++ b/doc/appendix-release-notes.xml @@ -46,6 +46,13 @@ for all databases in the cluster, ignore the cluster size query if it fails. + + + &repmgrd;: ensure the witness node record on the primary is always marked + as active if previously marked inactive. + GitHub #754. + + diff --git a/repmgrd-physical.c b/repmgrd-physical.c index 9a2624d4..ef316490 100644 --- a/repmgrd-physical.c +++ b/repmgrd-physical.c @@ -2382,6 +2382,18 @@ monitor_streaming_witness(void) log_warning(_("unable to retrieve node record from primary")); } + /* refresh local node record from the primary */ + record_status = get_node_record(primary_conn, config_file_options.node_id, &local_node_info); + + if (record_status != RECORD_FOUND) + { + log_error(_("no metadata record found for this node on the current primary - terminating")); + log_hint(_("check that 'repmgr witness register' was executed for this node")); + close_connection(&primary_conn); + close_connection(&local_conn); + terminate(ERR_BAD_CONFIG); + } + initPQExpBuffer(&event_details); appendPQExpBuffer(&event_details,