From 18cd8904749fea0a644b10cb1db09f35fc93898f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Thu, 28 Mar 2019 10:46:38 +0200 Subject: [PATCH] Fix binlogrouter slave heartbeat task addition The task was added multiple times when only one task is needed. --- server/modules/routing/binlogrouter/blr.cc | 1 + server/modules/routing/binlogrouter/blr.hh | 1 + server/modules/routing/binlogrouter/blr_slave.cc | 4 +++- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/server/modules/routing/binlogrouter/blr.cc b/server/modules/routing/binlogrouter/blr.cc index 6dfe4240d..bbd805302 100644 --- a/server/modules/routing/binlogrouter/blr.cc +++ b/server/modules/routing/binlogrouter/blr.cc @@ -354,6 +354,7 @@ static MXS_ROUTER* createInstance(SERVICE* service, MXS_CONFIG_PARAMETER* params inst->trx_safe = params->get_bool("transaction_safety"); inst->fileroot = params->get_c_str_copy("filestem"); inst->heartbeat_task_active = false; + inst->slave_heartbeat_task_active = false; /* Server id */ inst->serverid = params->get_integer("server_id"); diff --git a/server/modules/routing/binlogrouter/blr.hh b/server/modules/routing/binlogrouter/blr.hh index 1d0e564bb..bbccc09f1 100644 --- a/server/modules/routing/binlogrouter/blr.hh +++ b/server/modules/routing/binlogrouter/blr.hh @@ -800,6 +800,7 @@ struct ROUTER_INSTANCE : public MXS_ROUTER unsigned long burst_size; /*< Maximum size of burst to send */ unsigned long heartbeat; /*< Configured heartbeat value */ bool heartbeat_task_active; + bool slave_heartbeat_task_active; ROUTER_STATS stats; /*< Statistics for this router */ int active_logs; int reconnect_pending; diff --git a/server/modules/routing/binlogrouter/blr_slave.cc b/server/modules/routing/binlogrouter/blr_slave.cc index 9b6783d4a..19a9cfb3a 100644 --- a/server/modules/routing/binlogrouter/blr_slave.cc +++ b/server/modules/routing/binlogrouter/blr_slave.cc @@ -425,8 +425,10 @@ int blr_slave_request(ROUTER_INSTANCE* router, ROUTER_SLAVE* slave, GWBUF* queue /* Check whether to add the heartbeat check for this slave */ if (rv && slave->state == BLRS_DUMPING && router->send_slave_heartbeat - && slave->heartbeat > 0) + && slave->heartbeat > 0 + && !router->slave_heartbeat_task_active) { + router->slave_heartbeat_task_active = true; char task_name[BLRM_TASK_NAME_LEN + 1] = ""; snprintf(task_name, BLRM_TASK_NAME_LEN,