Fix server usage bugs in monitors and servers

The MySQL Monitor did not reset the pointer to the root master reference
which would lead to a crash if the master was removed.

When service details were shown, it listed all servers that existed. Only
servers that haven't been removed or destroyed should be shown.
This commit is contained in:
Markus Makela
2016-11-11 08:31:28 +02:00
parent e67a829daf
commit 16e8aa7178
3 changed files with 12 additions and 11 deletions

View File

@ -330,7 +330,6 @@ void monitorRemoveServer(MONITOR *mon, SERVER *server)
spinlock_acquire(&mon->lock);
ss_dassert(mon->databases);
MONITOR_SERVERS *ptr = mon->databases;
if (ptr->server == server)
@ -1109,12 +1108,9 @@ void
mon_log_connect_error(MONITOR_SERVERS* database, connect_result_t rval)
{
MXS_ERROR(rval == MONITOR_CONN_TIMEOUT ?
"Monitor timed out when connecting to "
"server %s:%d : \"%s\"" :
"Monitor was unable to connect to "
"server %s:%d : \"%s\"",
database->server->name,
database->server->port,
"Monitor timed out when connecting to server %s:%d : \"%s\"" :
"Monitor was unable to connect to server %s:%d : \"%s\"",
database->server->name, database->server->port,
mysql_error(database->con));
}

View File

@ -1365,8 +1365,11 @@ void dprintService(DCB *dcb, SERVICE *service)
dcb_printf(dcb, "\tBackend databases:\n");
while (server)
{
dcb_printf(dcb, "\t\t%s:%d Protocol: %s\n", server->server->name, server->server->port,
server->server->protocol);
if (server->active && server->server->is_active)
{
dcb_printf(dcb, "\t\t%s:%d Protocol: %s\n", server->server->name,
server->server->port, server->server->protocol);
}
server = server->next;
}
if (service->weightby)
@ -2201,7 +2204,7 @@ bool service_server_in_use(const SERVER *server)
for (SERVER_REF *ref = service->dbref; ref && !rval; ref = ref->next)
{
if (ref->server == server)
if (ref->active && ref->server == server)
{
rval = true;
}

View File

@ -270,7 +270,6 @@ startMonitor(MONITOR *monitor, const CONFIG_PARAMETER* params)
handle->replicationHeartbeat = 0;
handle->detectStaleMaster = true;
handle->detectStaleSlave = true;
handle->master = NULL;
handle->script = NULL;
handle->multimaster = false;
handle->mysql51_replication = false;
@ -281,6 +280,9 @@ startMonitor(MONITOR *monitor, const CONFIG_PARAMETER* params)
spinlock_init(&handle->lock);
}
/** This should always be reset to NULL */
handle->master = NULL;
while (params)
{
if (!strcmp(params->name, "detect_stale_master"))