Remove depth field from SERVER
It was not really used anymore.
This commit is contained in:
@ -386,7 +386,6 @@ MXS_MONITORED_SERVER *GaleraMonitor::get_candidate_master()
|
||||
(moitor_servers->pending_status & SERVER_JOINED))
|
||||
{
|
||||
|
||||
moitor_servers->server->depth = 0;
|
||||
char buf[50]; // Enough to hold most numbers
|
||||
if (m_use_priority && server_get_parameter(moitor_servers->server, "priority", buf, sizeof(buf)))
|
||||
{
|
||||
|
||||
@ -297,18 +297,12 @@ void MMMonitor::update_server_status(MXS_MONITORED_SERVER* monitored_server)
|
||||
{
|
||||
monitor_clear_pending_status(monitored_server, SERVER_SLAVE);
|
||||
monitor_set_pending_status(monitored_server, SERVER_MASTER);
|
||||
|
||||
/* Set replication depth to 0 */
|
||||
monitored_server->server->depth = 0;
|
||||
}
|
||||
else if (isslave)
|
||||
{
|
||||
monitor_set_pending_status(monitored_server, SERVER_SLAVE);
|
||||
/* Avoid any possible stale Master state */
|
||||
monitor_clear_pending_status(monitored_server, SERVER_MASTER);
|
||||
|
||||
/* Set replication depth to 1 */
|
||||
monitored_server->server->depth = 1;
|
||||
}
|
||||
/* Avoid any possible Master/Slave stale state */
|
||||
else
|
||||
@ -382,7 +376,7 @@ MXS_MONITORED_SERVER *MMMonitor::get_current_master()
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ptr->server->depth == 0)
|
||||
if (ptr->pending_status & SERVER_MASTER)
|
||||
{
|
||||
m_master = ptr;
|
||||
}
|
||||
|
||||
@ -115,12 +115,10 @@ void NDBCMonitor::update_server_status(MXS_MONITORED_SERVER* monitored_server)
|
||||
if (isjoined)
|
||||
{
|
||||
monitor_set_pending_status(monitored_server, SERVER_NDB);
|
||||
monitored_server->server->depth = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
monitor_clear_pending_status(monitored_server, SERVER_NDB);
|
||||
monitored_server->server->depth = -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -856,42 +856,28 @@ static uint64_t getCapabilities(MXS_ROUTER* instance)
|
||||
return RCAP_TYPE_NONE;
|
||||
}
|
||||
|
||||
/********************************
|
||||
* This routine returns the root master server from MySQL replication tree
|
||||
* Get the root Master rule:
|
||||
/*
|
||||
* This routine returns the master server from a MariaDB replication tree. The server must be
|
||||
* running, not in maintenance and have the master bit set. If multiple masters are found,
|
||||
* the one with the highest weight is chosen.
|
||||
*
|
||||
* find server with the lowest replication depth level
|
||||
* and the SERVER_MASTER bitval
|
||||
* Servers are checked even if they are in 'maintenance'
|
||||
*
|
||||
* @param servers The list of servers
|
||||
* @return The Master found
|
||||
* @param servers The list of servers
|
||||
* @return The Master server
|
||||
*
|
||||
*/
|
||||
|
||||
static SERVER_REF *get_root_master(SERVER_REF *servers)
|
||||
{
|
||||
int i = 0;
|
||||
SERVER_REF *master_host = NULL;
|
||||
|
||||
for (SERVER_REF *ref = servers; ref; ref = ref->next)
|
||||
{
|
||||
if (ref->active && SERVER_IS_MASTER(ref->server))
|
||||
{
|
||||
if (master_host == NULL)
|
||||
// No master found yet or this one has higher weight.
|
||||
if (master_host == NULL || ref->weight > master_host->weight)
|
||||
{
|
||||
master_host = ref;
|
||||
}
|
||||
else if (ref->server->depth < master_host->server->depth ||
|
||||
(ref->server->depth == master_host->server->depth &&
|
||||
ref->weight > master_host->weight))
|
||||
{
|
||||
/**
|
||||
* This master has a lower depth than the candidate master or
|
||||
* the depths are equal but this master has a higher weight
|
||||
*/
|
||||
master_host = ref;
|
||||
}
|
||||
}
|
||||
}
|
||||
return master_host;
|
||||
|
||||
@ -244,14 +244,12 @@ static void log_server_connections(select_criteria_t criteria, const SRWBackendL
|
||||
SRWBackend get_root_master(const SRWBackendList& backends)
|
||||
{
|
||||
SRWBackend master;
|
||||
|
||||
for (auto it = backends.begin(); it != backends.end(); it++)
|
||||
for (auto candidate : backends)
|
||||
{
|
||||
auto b = *it;
|
||||
|
||||
if (b->is_master() && (!master || b->server()->depth < master->server()->depth))
|
||||
if (candidate->is_master())
|
||||
{
|
||||
master = b;
|
||||
master = candidate;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user