mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-26 16:46:28 +00:00
repmgr master unregister: tighten behaviour
This commit is contained in:
2
log.c
2
log.c
@@ -21,7 +21,7 @@
|
|||||||
#define DEFAULT_SYSLOG_FACILITY LOG_LOCAL0
|
#define DEFAULT_SYSLOG_FACILITY LOG_LOCAL0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define REPMGR_DEBUG
|
/* #define REPMGR_DEBUG */
|
||||||
|
|
||||||
static int detect_log_facility(const char *facility);
|
static int detect_log_facility(const char *facility);
|
||||||
static void _stderr_log_with_level(const char *level_name, int level, const char *fmt, va_list ap)
|
static void _stderr_log_with_level(const char *level_name, int level, const char *fmt, va_list ap)
|
||||||
|
|||||||
@@ -375,23 +375,39 @@ do_master_unregister(void)
|
|||||||
/* If we can connect to the node, perform some sanity checks on it */
|
/* If we can connect to the node, perform some sanity checks on it */
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
bool can_unregister = true;
|
||||||
t_recovery_type recovery_type = get_recovery_type(target_node_conn);
|
t_recovery_type recovery_type = get_recovery_type(target_node_conn);
|
||||||
|
|
||||||
/* Node appears to be a standby */
|
/* Node appears to be a standby */
|
||||||
if (recovery_type == RECTYPE_STANDBY)
|
if (recovery_type == RECTYPE_STANDBY)
|
||||||
{
|
{
|
||||||
|
/* We'll refuse to do anything unless the node record shows it as a master */
|
||||||
|
|
||||||
|
if (target_node_info_ptr->type != MASTER)
|
||||||
|
{
|
||||||
|
log_error(_("node %s (id: %i) is a %s, unable to unregister"),
|
||||||
|
target_node_info_ptr->node_name,
|
||||||
|
target_node_info_ptr->node_id,
|
||||||
|
get_node_type_string(target_node_info_ptr->type));
|
||||||
|
can_unregister = false;
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* If --F/--force not set, hint that it might be appropriate to
|
* If --F/--force not set, hint that it might be appropriate to
|
||||||
* register the node as a standby rather than unregister as master
|
* register the node as a standby rather than unregister as master
|
||||||
*/
|
*/
|
||||||
if (!runtime_options.force)
|
else if (!runtime_options.force)
|
||||||
{
|
{
|
||||||
log_error(_("node %s (id: %i) is a standby, unable to unregister"),
|
log_error(_("node %s (id: %i) is running as a standby, unable to unregister"),
|
||||||
target_node_info_ptr->node_name,
|
target_node_info_ptr->node_name,
|
||||||
target_node_info_ptr->node_id);
|
target_node_info_ptr->node_id);
|
||||||
log_hint(_("the node can be registered as a standby with \"repmgr standby register --force\""));
|
log_hint(_("the node can be registered as a standby with \"repmgr standby register --force\""));
|
||||||
log_hint(_("use \"repmgr master unregister --force\" to remove this node's metadata entirely"));
|
log_hint(_("use \"repmgr master unregister --force\" to remove this node's metadata entirely"));
|
||||||
|
can_unregister = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (can_unregister == false)
|
||||||
|
{
|
||||||
PQfinish(target_node_conn);
|
PQfinish(target_node_conn);
|
||||||
PQfinish(master_conn);
|
PQfinish(master_conn);
|
||||||
exit(ERR_BAD_CONFIG);
|
exit(ERR_BAD_CONFIG);
|
||||||
@@ -423,7 +439,7 @@ do_master_unregister(void)
|
|||||||
target_node_info_ptr->node_name,
|
target_node_info_ptr->node_name,
|
||||||
target_node_info_ptr->node_id);
|
target_node_info_ptr->node_id);
|
||||||
|
|
||||||
if (master_node_info.active == true)
|
if (master_node_info.active == false)
|
||||||
{
|
{
|
||||||
log_hint(_("node is marked as inactive, activate with \"repmgr master register --force\""));
|
log_hint(_("node is marked as inactive, activate with \"repmgr master register --force\""));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user