Don't execute "child_nodes_disconnect_command" when repmgrd paused

This commit is contained in:
Ian Barwick
2019-04-23 14:08:13 +09:00
parent 5a90513878
commit 6cbf436bf8

View File

@@ -121,6 +121,7 @@ static t_child_node_info *append_child_node_record(t_child_node_info_list *nodes
static void remove_child_node_record(t_child_node_info_list *nodes, int node_id); static void remove_child_node_record(t_child_node_info_list *nodes, int node_id);
static void clear_child_node_info_list(t_child_node_info_list *nodes); static void clear_child_node_info_list(t_child_node_info_list *nodes);
static void parse_child_nodes_disconnect_command(char *parsed_command, char *template, int reporting_node_id); static void parse_child_nodes_disconnect_command(char *parsed_command, char *template, int reporting_node_id);
static void execute_child_nodes_disconnect_command(NodeInfoList *db_child_node_records, t_child_node_info_list *local_child_nodes);
void void
handle_sigint_physical(SIGNAL_ARGS) handle_sigint_physical(SIGNAL_ARGS)
@@ -992,6 +993,23 @@ check_primary_child_nodes(t_child_node_info_list *local_child_nodes)
if (config_file_options.child_nodes_disconnect_command[0] != '\0') if (config_file_options.child_nodes_disconnect_command[0] != '\0')
{
bool repmgrd_paused = repmgrd_is_paused(local_conn);
if (repmgrd_paused == false)
execute_child_nodes_disconnect_command(&db_child_node_records, local_child_nodes);
}
clear_child_node_info_list(&disconnected_child_nodes);
clear_child_node_info_list(&reconnected_child_nodes);
clear_child_node_info_list(&new_child_nodes);
clear_node_info_list(&db_child_node_records);
}
void
execute_child_nodes_disconnect_command(NodeInfoList *db_child_node_records, t_child_node_info_list *local_child_nodes)
{ {
/* /*
* script will only be executed if the number of attached * script will only be executed if the number of attached
@@ -999,9 +1017,12 @@ check_primary_child_nodes(t_child_node_info_list *local_child_nodes)
*/ */
int min_required_connected_count = 1; int min_required_connected_count = 1;
int connected_count = 0; int connected_count = 0;
NodeInfoListCell *cell;
/* /*
* Calculate hi * Calculate minimum number of nodes which need to be connected
* (if the total falls below that, "child_nodes_disconnect_command"
* will be executed)
*/ */
if (config_file_options.child_nodes_connected_min_count > 0) if (config_file_options.child_nodes_connected_min_count > 0)
@@ -1011,12 +1032,12 @@ check_primary_child_nodes(t_child_node_info_list *local_child_nodes)
else if (config_file_options.child_nodes_disconnect_min_count > 0) else if (config_file_options.child_nodes_disconnect_min_count > 0)
{ {
min_required_connected_count = min_required_connected_count =
(db_child_node_records.node_count - config_file_options.child_nodes_disconnect_min_count) (db_child_node_records->node_count - config_file_options.child_nodes_disconnect_min_count)
+ 1; + 1;
} }
/* calculate number of connected child nodes */ /* calculate number of connected child nodes */
for (cell = db_child_node_records.head; cell; cell = cell->next) for (cell = db_child_node_records->head; cell; cell = cell->next)
{ {
if (cell->node_info->attached == NODE_ATTACHED) if (cell->node_info->attached == NODE_ATTACHED)
connected_count ++; connected_count ++;
@@ -1030,7 +1051,7 @@ check_primary_child_nodes(t_child_node_info_list *local_child_nodes)
{ {
log_notice(_("%i (of %i) child nodes are connected, but at least %i child nodes required"), log_notice(_("%i (of %i) child nodes are connected, but at least %i child nodes required"),
connected_count, connected_count,
db_child_node_records.node_count, db_child_node_records->node_count,
min_required_connected_count); min_required_connected_count);
if (child_nodes_disconnect_command_executed == false) if (child_nodes_disconnect_command_executed == false)
@@ -1154,20 +1175,13 @@ check_primary_child_nodes(t_child_node_info_list *local_child_nodes)
{ {
log_notice(_("%i (of %i) child nodes are now connected, meeting minimum requirement of %i child nodes"), log_notice(_("%i (of %i) child nodes are now connected, meeting minimum requirement of %i child nodes"),
connected_count, connected_count,
db_child_node_records.node_count, db_child_node_records->node_count,
min_required_connected_count); min_required_connected_count);
child_nodes_disconnect_command_executed = false; child_nodes_disconnect_command_executed = false;
} }
} }
} }
clear_child_node_info_list(&disconnected_child_nodes);
clear_child_node_info_list(&reconnected_child_nodes);
clear_child_node_info_list(&new_child_nodes);
clear_node_info_list(&db_child_node_records);
}
/* /*
* repmgrd running on a standby server * repmgrd running on a standby server