diff --git a/HISTORY b/HISTORY
index 65071b52..4211785c 100644
--- a/HISTORY
+++ b/HISTORY
@@ -1,5 +1,8 @@
+5.4.1 2023-??-??
+ repmgrd: ensure witness node metadata is updated (Ian)
+
5.4.0 2023-03-16
- Support cloning replicas using pg-backup-api
+ Support cloning replicas using pg-backup-api
5.3.3 2022-10-17
Support for PostgreSQL added
diff --git a/doc/appendix-release-notes.xml b/doc/appendix-release-notes.xml
index 39ee8c7d..fea4681d 100644
--- a/doc/appendix-release-notes.xml
+++ b/doc/appendix-release-notes.xml
@@ -16,8 +16,29 @@
+
+ Release 5.4.1
+ ??? ?? ??????, 202?
+
+ &repmgr; 5.4.1 is a minor release providing ...
+
+
+ Bug fixes
+
+
+
+
+ &repmgrd;: ensure witness node metadata is updated if the primary
+ node changed while the witness &repmgrd; was not running.
+
+
+
+
+
+
+
- Release 5.4.0
+ Release 5.4.0
Thu 15 March, 2023
&repmgr; 5.4.0 is a major release.
@@ -29,6 +50,7 @@
Minor fixes to the documentation.
+
Release 5.3.3
diff --git a/repmgrd-physical.c b/repmgrd-physical.c
index 03247437..0746c2a6 100644
--- a/repmgrd-physical.c
+++ b/repmgrd-physical.c
@@ -2394,6 +2394,17 @@ monitor_streaming_witness(void)
terminate(ERR_BAD_CONFIG);
}
+ /*
+ * It's possible that the primary changed while the witness repmgrd was not
+ * running. This does not affect the functionality of the witness repmgrd, but
+ * does mean outdated node metadata will be displayed, so update that.
+ */
+ if (local_node_info.upstream_node_id != primary_node_id)
+ {
+ update_node_record_set_upstream(primary_conn, local_node_info.node_id, primary_node_id);
+ local_node_info.upstream_node_id = primary_node_id;
+ }
+
initPQExpBuffer(&event_details);
appendPQExpBuffer(&event_details,