diff --git a/dbutils.c b/dbutils.c
index d8d7f404..22ab1b85 100644
--- a/dbutils.c
+++ b/dbutils.c
@@ -4242,7 +4242,7 @@ _create_event(PGconn *conn, t_configuration_options *options, int node_id, char
}
break;
case 'p':
- /* %p: primary id ("standby_switchover": former primary id) */
+ /* %p: primary id ("standby_switchover"/"repmgrd_failover_promote": former primary id) */
src_ptr++;
if (event_info->node_id != UNKNOWN_NODE_ID)
{
diff --git a/doc/appendix-release-notes.xml b/doc/appendix-release-notes.xml
index b2139ed5..d94d26a6 100644
--- a/doc/appendix-release-notes.xml
+++ b/doc/appendix-release-notes.xml
@@ -77,7 +77,16 @@
status.
+
+
+
+ Add %p event notification parameter
+ providing the node ID of the former primary for the repmgrd_failover_promote event.
+
+
+
+
diff --git a/doc/event-notifications.xml b/doc/event-notifications.xml
index ce4a06ed..860f884c 100644
--- a/doc/event-notifications.xml
+++ b/doc/event-notifications.xml
@@ -95,7 +95,8 @@
- The following parameters are provided for a subset of event notifications:
+ The following parameters are provided for a subset of event notifications; their meaning may
+ change according to context:
@@ -108,6 +109,9 @@
node ID of the demoted primary ( only)
+
+ node ID of the former primary (repmgrd_failover_promote only)
+
@@ -133,7 +137,7 @@
The values provided for %c and %a
- will probably contain spaces, so should always be quoted.
+ may contain spaces, so should always be quoted.
diff --git a/repmgrd-physical.c b/repmgrd-physical.c
index ddf0f0fe..44f24368 100644
--- a/repmgrd-physical.c
+++ b/repmgrd-physical.c
@@ -1842,6 +1842,7 @@ monitor_streaming_standby(void)
int former_upstream_node_id = local_node_info.upstream_node_id;
NodeInfoList sibling_nodes = T_NODE_INFO_LIST_INITIALIZER;
PQExpBufferData event_details;
+ t_event_info event_info = T_EVENT_INFO_INITIALIZER;
update_node_record_set_primary(local_conn, local_node_info.node_id);
record_status = get_node_record(local_conn, local_node_info.node_id, &local_node_info);
@@ -1854,12 +1855,16 @@ monitor_streaming_standby(void)
initPQExpBuffer(&event_details);
appendPQExpBufferStr(&event_details,
_("promotion command failed but promotion completed successfully"));
- create_event_notification(local_conn,
- &config_file_options,
- local_node_info.node_id,
- "repmgrd_failover_promote",
- true,
- event_details.data);
+
+ event_info.node_id = former_upstream_node_id;
+
+ create_event_notification_extended(local_conn,
+ &config_file_options,
+ local_node_info.node_id,
+ "repmgrd_failover_promote",
+ true,
+ event_details.data,
+ &event_info);
termPQExpBuffer(&event_details);
@@ -3703,6 +3708,7 @@ promote_self(void)
{
PQExpBufferData event_details;
+ t_event_info event_info = T_EVENT_INFO_INITIALIZER;
/* update own internal node record */
record_status = get_node_record(local_conn, local_node_info.node_id, &local_node_info);
@@ -3719,13 +3725,16 @@ promote_self(void)
failed_primary.node_name,
failed_primary.node_id);
+ event_info.node_id = failed_primary.node_id;
+
/* local_conn is now the primary connection */
- create_event_notification(local_conn,
- &config_file_options,
- local_node_info.node_id,
- "repmgrd_failover_promote",
- true,
- event_details.data);
+ create_event_notification_extended(local_conn,
+ &config_file_options,
+ local_node_info.node_id,
+ "repmgrd_failover_promote",
+ true,
+ event_details.data,
+ &event_info);
termPQExpBuffer(&event_details);
}