repmgrd: optionally exclude/include witness server from child node checks

This commit is contained in:
Ian Barwick
2019-06-03 14:33:34 +09:00
committed by Ian Barwick
parent e8731f8159
commit d893ce227b
4 changed files with 47 additions and 3 deletions

View File

@@ -1026,7 +1026,10 @@ check_primary_child_nodes(t_child_node_info_list *local_child_nodes)
bool repmgrd_paused = repmgrd_is_paused(local_conn);
if (repmgrd_paused == false)
{
/* check criteria for execution, and execute if criteria met */
execute_child_nodes_disconnect_command(&db_child_node_records, local_child_nodes);
}
}
clear_child_node_info_list(&disconnected_child_nodes);
@@ -1060,14 +1063,34 @@ execute_child_nodes_disconnect_command(NodeInfoList *db_child_node_records, t_ch
}
else if (config_file_options.child_nodes_disconnect_min_count > 0)
{
int child_node_count = db_child_node_records->node_count;
if (config_file_options.child_nodes_connected_include_witness == false)
{
/* reduce total, if witness server in child node list */
for (cell = db_child_node_records->head; cell; cell = cell->next)
{
if (cell->node_info->type == WITNESS)
{
child_node_count--;
break;
}
}
}
min_required_connected_count =
(db_child_node_records->node_count - config_file_options.child_nodes_disconnect_min_count)
(child_node_count - config_file_options.child_nodes_disconnect_min_count)
+ 1;
}
/* calculate number of connected child nodes */
for (cell = db_child_node_records->head; cell; cell = cell->next)
{
/* exclude witness server from total, if necessay */
if (config_file_options.child_nodes_connected_include_witness == false &&
cell->node_info->type == WITNESS)
continue;
if (cell->node_info->attached == NODE_ATTACHED)
connected_count ++;
}
@@ -1101,6 +1124,11 @@ execute_child_nodes_disconnect_command(NodeInfoList *db_child_node_records, t_ch
instr_time current_time = current_time_base;
int seconds_since_detached;
/* exclude witness server from calculatin if neccessary */
if (config_file_options.child_nodes_connected_include_witness == false &&
child_node_rec->type == WITNESS)
continue;
if (child_node_rec->attached != NODE_DETACHED)
continue;