Remove depth field from SERVER

It was not really used anymore.
This commit is contained in:
Esa Korhonen 2018-06-27 14:07:12 +03:00
parent 960d08a36a
commit a59c0c61ce
7 changed files with 13 additions and 42 deletions

View File

@ -156,7 +156,6 @@ typedef struct server
int rlag; /**< Replication Lag for Master/Slave replication */
unsigned long node_ts; /**< Last timestamp set from M/S monitor module */
long master_id; /**< Master server id of this node */
int depth; /**< Replication level in the tree */
// Misc fields
bool master_err_is_logged; /**< If node failed, this indicates whether it is logged. Only used
* by rwsplit. TODO: Move to rwsplit */

View File

@ -128,7 +128,6 @@ SERVER* server_alloc(const char *name, const char *address, unsigned short port,
server->node_id = -1;
server->rlag = MAX_RLAG_UNDEFINED;
server->master_id = -1;
server->depth = -1;
server->parameters = NULL;
spinlock_init(&server->lock);
server->persistent = persistent;
@ -519,7 +518,6 @@ dprintServer(DCB *dcb, const SERVER *server)
mon_get_event_name((mxs_monitor_event_t)server->last_event));
time_t t = maxscale_started() + MXS_CLOCK_TO_SEC(server->triggered_at);
dcb_printf(dcb, "\tTriggered at: %s\n", http_to_date(t).c_str());
dcb_printf(dcb, "\tRepl Depth: %d\n", server->depth);
if (SERVER_IS_SLAVE(server) || SERVER_IS_RELAY_SERVER(server))
{
if (server->rlag >= 0)
@ -1481,7 +1479,6 @@ static json_t* server_json_attributes(const SERVER* server)
json_object_set_new(attr, "node_id", json_integer(server->node_id));
json_object_set_new(attr, "master_id", json_integer(server->master_id));
json_object_set_new(attr, "replication_depth", json_integer(server->depth));
const char* event_name = mon_get_event_name((mxs_monitor_event_t)server->last_event);
time_t t = maxscale_started() + MXS_CLOCK_TO_SEC(server->triggered_at);

View File

@ -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)))
{

View File

@ -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;
}

View File

@ -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;
}
}

View File

@ -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;

View File

@ -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;
}
}