mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-27 17:06:29 +00:00
primary unregister: ensure correct behaviour when executed on a witness
Fixes GitHub #548.
This commit is contained in:
2
HISTORY
2
HISTORY
@@ -12,6 +12,8 @@
|
|||||||
data directory on the demotion candidate; GitHub #523 (Ian)
|
data directory on the demotion candidate; GitHub #523 (Ian)
|
||||||
repmgr: ensure "standby switchover" verifies replication connection
|
repmgr: ensure "standby switchover" verifies replication connection
|
||||||
exists; GitHub #519 (Ian)
|
exists; GitHub #519 (Ian)
|
||||||
|
repmgr: ensure "primary unregister" behaves correctly when executed
|
||||||
|
on a witness server; GitHub #548 (Ian)
|
||||||
repmgr: when executing "standby follow" and "node rejoin", check that
|
repmgr: when executing "standby follow" and "node rejoin", check that
|
||||||
it will actually be possible to stream from the target node (Ian)
|
it will actually be possible to stream from the target node (Ian)
|
||||||
repmgr: "standby switchover": improve handling of connection URIs when
|
repmgr: "standby switchover": improve handling of connection URIs when
|
||||||
|
|||||||
@@ -173,7 +173,7 @@ REPMGRD_OPTS="--daemonize=false"</programlisting>
|
|||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
&repmgr;: when executing <command><link linkend="repmgr-witness-register">repmgr witness register</link></command>,
|
&repmgr;: when executing <command><link linkend="repmgr-witness-register">repmgr witness register</link></command>,
|
||||||
chech the node to connected is actually the primary (i.e. not the witness server). (GitHub #528).
|
chech the node to connected is actually the primary (i.e. not the witness server). GitHub #528.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
|
||||||
@@ -207,6 +207,13 @@ REPMGRD_OPTS="--daemonize=false"</programlisting>
|
|||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
ensure <command><link linkend="repmgr-primary-unregister">repmgr primary unregister</link></command>
|
||||||
|
behaves correctly when executed on a witness server. GitHub #548.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
|
||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
</para>
|
</para>
|
||||||
</sect2>
|
</sect2>
|
||||||
|
|||||||
@@ -251,6 +251,7 @@ do_primary_unregister(void)
|
|||||||
PGconn *primary_conn = NULL;
|
PGconn *primary_conn = NULL;
|
||||||
PGconn *local_conn = NULL;
|
PGconn *local_conn = NULL;
|
||||||
t_node_info local_node_info = T_NODE_INFO_INITIALIZER;
|
t_node_info local_node_info = T_NODE_INFO_INITIALIZER;
|
||||||
|
t_node_info primary_node_info = T_NODE_INFO_INITIALIZER;
|
||||||
|
|
||||||
t_node_info *target_node_info_ptr = NULL;
|
t_node_info *target_node_info_ptr = NULL;
|
||||||
PGconn *target_node_conn = NULL;
|
PGconn *target_node_conn = NULL;
|
||||||
@@ -271,8 +272,6 @@ do_primary_unregister(void)
|
|||||||
|
|
||||||
if (PQstatus(primary_conn) != CONNECTION_OK)
|
if (PQstatus(primary_conn) != CONNECTION_OK)
|
||||||
{
|
{
|
||||||
t_node_info primary_node_info = T_NODE_INFO_INITIALIZER;
|
|
||||||
|
|
||||||
log_error(_("unable to connect to primary server"));
|
log_error(_("unable to connect to primary server"));
|
||||||
|
|
||||||
if (get_primary_node_record(local_conn, &primary_node_info) == true)
|
if (get_primary_node_record(local_conn, &primary_node_info) == true)
|
||||||
@@ -291,10 +290,19 @@ do_primary_unregister(void)
|
|||||||
/* Local connection no longer required */
|
/* Local connection no longer required */
|
||||||
PQfinish(local_conn);
|
PQfinish(local_conn);
|
||||||
|
|
||||||
|
if (get_primary_node_record(primary_conn, &primary_node_info) == false)
|
||||||
|
{
|
||||||
|
log_error(_("unable to retrieve record for primary node"));
|
||||||
|
PQfinish(primary_conn);
|
||||||
|
exit(ERR_BAD_CONFIG);
|
||||||
|
}
|
||||||
|
|
||||||
/* Target node is local node? */
|
/* Target node is local node? */
|
||||||
if (target_node_info.node_id == UNKNOWN_NODE_ID
|
if (target_node_info.node_id == UNKNOWN_NODE_ID)
|
||||||
|| target_node_info.node_id == config_file_options.node_id)
|
{
|
||||||
|
target_node_info_ptr = &primary_node_info;
|
||||||
|
}
|
||||||
|
else if (target_node_info.node_id == config_file_options.node_id)
|
||||||
{
|
{
|
||||||
target_node_info_ptr = &local_node_info;
|
target_node_info_ptr = &local_node_info;
|
||||||
}
|
}
|
||||||
@@ -304,6 +312,24 @@ do_primary_unregister(void)
|
|||||||
target_node_info_ptr = &target_node_info;
|
target_node_info_ptr = &target_node_info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Sanity-check the target node is not a witness
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (target_node_info_ptr->type == WITNESS)
|
||||||
|
{
|
||||||
|
log_error(_("node %s (id: %i) is a witness server, unable to unregister"),
|
||||||
|
target_node_info_ptr->node_name,
|
||||||
|
target_node_info_ptr->node_id);
|
||||||
|
if (target_node_info_ptr->type == STANDBY)
|
||||||
|
{
|
||||||
|
log_hint(_("the node can be unregistered with \"repmgr witness unregister\""));
|
||||||
|
}
|
||||||
|
|
||||||
|
PQfinish(primary_conn);
|
||||||
|
exit(ERR_BAD_CONFIG);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check for downstream nodes - if any still defined, we won't be able to
|
* Check for downstream nodes - if any still defined, we won't be able to
|
||||||
* delete the node record due to foreign key constraints.
|
* delete the node record due to foreign key constraints.
|
||||||
|
|||||||
Reference in New Issue
Block a user