Assign master status only to root level masters
If a relay master server is found in the replication tree, it should not get the master status. Previously all master servers were assigned the master status regardless of their depth in the replication tree. By comparing the depth value of each potential master, the monitor can find the right master at the root of the replication tree.
This commit is contained in:
parent
46c8a6f66b
commit
506ef1b9f6
@ -619,7 +619,7 @@ server_status(SERVER *server)
|
||||
{
|
||||
char *status = NULL;
|
||||
|
||||
if (NULL == server || (status = (char *)MXS_MALLOC(256)) == NULL)
|
||||
if (NULL == server || (status = (char *)MXS_MALLOC(512)) == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
@ -632,6 +632,10 @@ server_status(SERVER *server)
|
||||
{
|
||||
strcat(status, "Master, ");
|
||||
}
|
||||
if (server->status & SERVER_RELAY_MASTER)
|
||||
{
|
||||
strcat(status, "Relay Master, ");
|
||||
}
|
||||
if (server->status & SERVER_SLAVE)
|
||||
{
|
||||
strcat(status, "Slave, ");
|
||||
|
@ -129,6 +129,7 @@ typedef struct server
|
||||
#define SERVER_MASTER_STICKINESS 0x0100 /**<< Server Master stickiness */
|
||||
#define SERVER_AUTH_ERROR 0x1000 /**<< Authentication error from monitor */
|
||||
#define SERVER_STALE_SLAVE 0x2000 /**<< Slave status is possible even without a master */
|
||||
#define SERVER_RELAY_MASTER 0x4000 /**<< Server is a relay master */
|
||||
|
||||
/**
|
||||
* Is the server running - the macro returns true if the server is marked as running
|
||||
|
@ -900,6 +900,7 @@ monitorDatabase(MONITOR *mon, MONITOR_SERVERS *database)
|
||||
server_clear_status(database->server, SERVER_MASTER);
|
||||
monitor_clear_pending_status(database, SERVER_SLAVE);
|
||||
monitor_clear_pending_status(database, SERVER_MASTER);
|
||||
monitor_clear_pending_status(database, SERVER_RELAY_MASTER);
|
||||
|
||||
/* Clean addition status too */
|
||||
server_clear_status(database->server, SERVER_SLAVE_OF_EXTERNAL_MASTER);
|
||||
@ -1378,6 +1379,23 @@ monitorMain(void *arg)
|
||||
find_graph_cycles(handle, mon->databases, num_servers);
|
||||
}
|
||||
|
||||
ptr = mon->databases;
|
||||
while (ptr)
|
||||
{
|
||||
MYSQL_SERVER_INFO *serv_info = hashtable_fetch(handle->server_info, ptr->server->unique_name);
|
||||
ss_dassert(serv_info);
|
||||
|
||||
if (getSlaveOfNodeId(mon->databases, ptr->server->node_id) &&
|
||||
getServerByNodeId(mon->databases, ptr->server->master_id) &&
|
||||
(!handle->multimaster || serv_info->group == 0))
|
||||
{
|
||||
/** This server is both a slave and a master i.e. a relay master */
|
||||
monitor_set_pending_status(ptr, SERVER_RELAY_MASTER);
|
||||
monitor_clear_pending_status(ptr, SERVER_MASTER);
|
||||
}
|
||||
ptr = ptr->next;
|
||||
}
|
||||
|
||||
/* Update server status from monitor pending status on that server*/
|
||||
|
||||
ptr = mon->databases;
|
||||
@ -1899,6 +1917,14 @@ static MONITOR_SERVERS *get_replication_tree(MONITOR *mon, int num_servers)
|
||||
add_slave_to_master(master->server->slaves, sizeof(master->server->slaves),
|
||||
current->node_id);
|
||||
master->server->depth = current->depth - 1;
|
||||
|
||||
if(handle->master && master->server->depth < handle->master->server->depth)
|
||||
{
|
||||
/** A master with a lower depth was found, remove
|
||||
the master status from the previous master. */
|
||||
monitor_clear_pending_status(handle->master, SERVER_MASTER);
|
||||
}
|
||||
|
||||
monitor_set_pending_status(master, SERVER_MASTER);
|
||||
handle->master = master;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user