Merge branch '2.3' into 2.4

This commit is contained in:
Markus Mäkelä
2019-07-10 09:23:20 +03:00

View File

@ -489,13 +489,12 @@ MonitorServer* GaleraMonitor::get_candidate_master()
if (!moitor_servers->server->is_in_maint() if (!moitor_servers->server->is_in_maint()
&& (moitor_servers->pending_status & SERVER_JOINED)) && (moitor_servers->pending_status & SERVER_JOINED))
{ {
if (m_use_priority) std::string priority = moitor_servers->server->get_custom_parameter("priority");
{
std::string buf = moitor_servers->server->get_custom_parameter("priority"); if (m_use_priority && !priority.empty())
if (!buf.empty())
{ {
/** The server has a priority */ /** The server has a priority */
if ((currval = atoi(buf.c_str())) > 0) if ((currval = atoi(priority.c_str())) > 0)
{ {
/** The priority is valid */ /** The priority is valid */
if (currval < minval && currval > 0) if (currval < minval && currval > 0)
@ -505,10 +504,15 @@ MonitorServer* GaleraMonitor::get_candidate_master()
} }
} }
} }
} else if (moitor_servers->server->node_id >= 0)
else if (moitor_servers->server->node_id >= 0
&& (!m_use_priority || candidate_master == NULL))
{ {
if (m_use_priority && candidate_master
&& !candidate_master->server->get_custom_parameter("priority").empty())
{
// 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 // Server priorities are not in use or no candidate has been found
if (min_id < 0 || moitor_servers->server->node_id < min_id) if (min_id < 0 || moitor_servers->server->node_id < min_id)
{ {