MXS-2594: Fix priority usage without node priorities

The first node without a priority would be chosen as the candidate master
and the rest would be ignored. The code must check if neither of the two
nodes have priorities and if so must choose the better one.
This commit is contained in:
Markus Mäkelä 2019-07-09 07:25:08 +03:00
parent 8d91e8e234
commit c7d90636b0
No known key found for this signature in database
GPG Key ID: 72D48FCE664F7B19

View File

@ -697,9 +697,15 @@ static MXS_MONITORED_SERVER *get_candidate_master(MXS_MONITOR* mon)
}
}
}
else if (moitor_servers->server->node_id >= 0 &&
(!handle->use_priority || candidate_master == NULL))
else if (moitor_servers->server->node_id >= 0)
{
if (handle->use_priority && candidate_master &&
server_get_parameter_nolock(moitor_servers->server, "priority", buf, sizeof(buf)))
{
// Current candidate has priority but this node doesn't, current candidate is better
continue;
}
// Server priorities are not in use or no candidate has been found
if (min_id < 0 || moitor_servers->server->node_id < min_id)
{