mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-22 22:56:29 +00:00
repmgrd: add %p event notification parameter for "repmgrd_failover_promote"
This enables an event notification script to identify the former primary node.
This commit is contained in:
@@ -4242,7 +4242,7 @@ _create_event(PGconn *conn, t_configuration_options *options, int node_id, char
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
/* %p: primary id ("standby_switchover": former primary id) */
|
/* %p: primary id ("standby_switchover"/"repmgrd_failover_promote": former primary id) */
|
||||||
src_ptr++;
|
src_ptr++;
|
||||||
if (event_info->node_id != UNKNOWN_NODE_ID)
|
if (event_info->node_id != UNKNOWN_NODE_ID)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -77,7 +77,16 @@
|
|||||||
status.
|
status.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Add <literal>%p</literal> <link linkend="event-notifications">event notification parameter</link>
|
||||||
|
providing the node ID of the former primary for the <literal>repmgrd_failover_promote</literal> event.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
|
||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
|
|
||||||
</para>
|
</para>
|
||||||
</sect2>
|
</sect2>
|
||||||
|
|
||||||
|
|||||||
@@ -95,7 +95,8 @@
|
|||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
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:
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<variablelist>
|
<variablelist>
|
||||||
@@ -108,6 +109,9 @@
|
|||||||
<para>
|
<para>
|
||||||
node ID of the demoted primary (<xref linkend="repmgr-standby-switchover"/> only)
|
node ID of the demoted primary (<xref linkend="repmgr-standby-switchover"/> only)
|
||||||
</para>
|
</para>
|
||||||
|
<para>
|
||||||
|
node ID of the former primary (<literal>repmgrd_failover_promote</literal> only)
|
||||||
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
@@ -133,7 +137,7 @@
|
|||||||
|
|
||||||
<para>
|
<para>
|
||||||
The values provided for <literal>%c</literal> and <literal>%a</literal>
|
The values provided for <literal>%c</literal> and <literal>%a</literal>
|
||||||
will probably contain spaces, so should always be quoted.
|
may contain spaces, so should always be quoted.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
|
|||||||
@@ -1842,6 +1842,7 @@ monitor_streaming_standby(void)
|
|||||||
int former_upstream_node_id = local_node_info.upstream_node_id;
|
int former_upstream_node_id = local_node_info.upstream_node_id;
|
||||||
NodeInfoList sibling_nodes = T_NODE_INFO_LIST_INITIALIZER;
|
NodeInfoList sibling_nodes = T_NODE_INFO_LIST_INITIALIZER;
|
||||||
PQExpBufferData event_details;
|
PQExpBufferData event_details;
|
||||||
|
t_event_info event_info = T_EVENT_INFO_INITIALIZER;
|
||||||
|
|
||||||
update_node_record_set_primary(local_conn, local_node_info.node_id);
|
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);
|
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);
|
initPQExpBuffer(&event_details);
|
||||||
appendPQExpBufferStr(&event_details,
|
appendPQExpBufferStr(&event_details,
|
||||||
_("promotion command failed but promotion completed successfully"));
|
_("promotion command failed but promotion completed successfully"));
|
||||||
create_event_notification(local_conn,
|
|
||||||
&config_file_options,
|
event_info.node_id = former_upstream_node_id;
|
||||||
local_node_info.node_id,
|
|
||||||
"repmgrd_failover_promote",
|
create_event_notification_extended(local_conn,
|
||||||
true,
|
&config_file_options,
|
||||||
event_details.data);
|
local_node_info.node_id,
|
||||||
|
"repmgrd_failover_promote",
|
||||||
|
true,
|
||||||
|
event_details.data,
|
||||||
|
&event_info);
|
||||||
|
|
||||||
termPQExpBuffer(&event_details);
|
termPQExpBuffer(&event_details);
|
||||||
|
|
||||||
@@ -3703,6 +3708,7 @@ promote_self(void)
|
|||||||
|
|
||||||
{
|
{
|
||||||
PQExpBufferData event_details;
|
PQExpBufferData event_details;
|
||||||
|
t_event_info event_info = T_EVENT_INFO_INITIALIZER;
|
||||||
|
|
||||||
/* update own internal node record */
|
/* update own internal node record */
|
||||||
record_status = get_node_record(local_conn, local_node_info.node_id, &local_node_info);
|
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_name,
|
||||||
failed_primary.node_id);
|
failed_primary.node_id);
|
||||||
|
|
||||||
|
event_info.node_id = failed_primary.node_id;
|
||||||
|
|
||||||
/* local_conn is now the primary connection */
|
/* local_conn is now the primary connection */
|
||||||
create_event_notification(local_conn,
|
create_event_notification_extended(local_conn,
|
||||||
&config_file_options,
|
&config_file_options,
|
||||||
local_node_info.node_id,
|
local_node_info.node_id,
|
||||||
"repmgrd_failover_promote",
|
"repmgrd_failover_promote",
|
||||||
true,
|
true,
|
||||||
event_details.data);
|
event_details.data,
|
||||||
|
&event_info);
|
||||||
|
|
||||||
termPQExpBuffer(&event_details);
|
termPQExpBuffer(&event_details);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user