MXS-2446 Do not assume created server exists

"Once you eliminate the impossible, whatever remains, no matter
 how improbable, must be the truth." Arthur Conan Doyle

Since server objects are never destroyed, currently the only
explanation for the crash described in MXS-2446 is that a server
created at runtime could not, immediately after the creation, be
found using its name.
This commit is contained in:
Johan Wikman 2019-05-06 11:04:25 +03:00
parent bc2d877898
commit 6f607e13de

View File

@ -561,22 +561,31 @@ bool ClustrixMonitor::refresh_nodes(MYSQL* pHub_con)
SERVER* pServer = SERVER::find_by_unique_name(server_name);
mxb_assert(pServer);
if (softfailed)
if (pServer)
{
pServer->set_status(SERVER_DRAINING);
if (softfailed)
{
pServer->set_status(SERVER_DRAINING);
}
const ClustrixMembership& membership = mit->second;
int health_check_threshold = m_config.health_check_threshold();
ClustrixNode node(this, membership, ip, mysql_port, health_port,
health_check_threshold, pServer);
m_nodes.insert(make_pair(id, node));
// New server, so it needs to be added to all services that
// use this monitor for defining its cluster of servers.
service_add_server(this, pServer);
}
else
{
MXS_ERROR("%s: Created server %s (at %s:%d) could not be "
"looked up using its name.",
name(), server_name.c_str(), ip.c_str(), mysql_port);
}
const ClustrixMembership& membership = mit->second;
int health_check_threshold = m_config.health_check_threshold();
ClustrixNode node(this, membership, ip, mysql_port, health_port,
health_check_threshold, pServer);
m_nodes.insert(make_pair(id, node));
// New server, so it needs to be added to all services that
// use this monitor for defining its cluster of servers.
service_add_server(this, pServer);
}
else
{