From 912cb711e39a2a158857b519fecabfec2915bc21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Thu, 13 Feb 2020 10:30:52 +0200 Subject: [PATCH] MXS-2844: Fix binlogrouter destruction Binlogrouter services can now be destroyed at runtime. --- server/core/service.cc | 2 +- server/modules/routing/binlogrouter/blr.cc | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/server/core/service.cc b/server/core/service.cc index b8a2498ae..9257aba4f 100644 --- a/server/core/service.cc +++ b/server/core/service.cc @@ -559,7 +559,7 @@ bool service_can_be_destroyed(Service* service) { bool rval = listener_find_by_service(service).empty(); - if (rval) + if (rval && strcmp(service->router_name(), "binlogrouter") != 0) { for (auto s = service->dbref; s; s = s->next) { diff --git a/server/modules/routing/binlogrouter/blr.cc b/server/modules/routing/binlogrouter/blr.cc index 0e1cada10..7d6b89a90 100644 --- a/server/modules/routing/binlogrouter/blr.cc +++ b/server/modules/routing/binlogrouter/blr.cc @@ -812,9 +812,12 @@ static MXS_ROUTER* createInstance(SERVICE* service, MXS_CONFIG_PARAMETER* params {"authenticator", "MySQLBackendAuth"} }, config_server_params); - Server* server = Server::server_alloc("binlog_router_master_host", params); + std::string my_name = "binlog_router_master_host_"; + my_name += service->name(); - if (server == NULL) + Server* server = Server::server_alloc(my_name.c_str(), params); + + if (!server && !(server = Server::find_by_unique_name(my_name))) { MXS_ERROR("%s: Error for server_alloc in createInstance", inst->service->name()); @@ -2869,6 +2872,9 @@ static void destroyInstance(MXS_ROUTER* instance) { ROUTER_INSTANCE* inst = (ROUTER_INSTANCE*) instance; + std::string task_name = inst->service->name() + std::string(" stats"); + hktask_remove(task_name.c_str()); + MXS_DEBUG("Destroying instance of router %s for service %s", inst->service->router_name(), inst->service->name());