From 6f607e13defd689d3d7ee0814035e3a289cbcfae Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Mon, 6 May 2019 11:04:25 +0300 Subject: [PATCH] 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. --- .../monitor/clustrixmon/clustrixmonitor.cc | 37 ++++++++++++------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/server/modules/monitor/clustrixmon/clustrixmonitor.cc b/server/modules/monitor/clustrixmon/clustrixmonitor.cc index 0a2f808bc..7f69f1c57 100644 --- a/server/modules/monitor/clustrixmon/clustrixmonitor.cc +++ b/server/modules/monitor/clustrixmon/clustrixmonitor.cc @@ -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 {