From 0e1d2ec1ec34cc91cfb7939cc19bd51696c0f82a Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Thu, 23 Aug 2018 14:53:45 +0300 Subject: [PATCH] MXS-2011 First check, then change By slightly re-arranging things, we do not need to revert the situation if some parameters are not acceptable, but can simply return. --- .../modules/routing/binlogrouter/blr_slave.cc | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/server/modules/routing/binlogrouter/blr_slave.cc b/server/modules/routing/binlogrouter/blr_slave.cc index 5813e063a..432e13700 100644 --- a/server/modules/routing/binlogrouter/blr_slave.cc +++ b/server/modules/routing/binlogrouter/blr_slave.cc @@ -4202,9 +4202,7 @@ int blr_handle_change_master(ROUTER_INSTANCE* router, "Cannot use MASTER_USE_GTID. " "Enable 'mariadb10_master_gtid' option first."); - blr_abort_change_master(router, - current_master, - error); + MXS_ERROR("%s: %s", router->service->name, error); spinlock_release(&router->lock); @@ -4214,10 +4212,11 @@ int blr_handle_change_master(ROUTER_INSTANCE* router, /** * Handle connection options */ + int h_val = -1; auto& master_heartbeat = change_master.heartbeat_period; if (!master_heartbeat.empty()) { - int h_val = (int)strtol(master_heartbeat.c_str(), NULL, 10); + h_val = (int)strtol(master_heartbeat.c_str(), NULL, 10); if (h_val < 0 || (errno == ERANGE) || @@ -4230,29 +4229,20 @@ int blr_handle_change_master(ROUTER_INSTANCE* router, "(%d seconds).", BLR_HEARTBEAT_MAX_INTERVAL); - blr_abort_change_master(router, - current_master, - error); + MXS_ERROR("%s: %s", router->service->name, error); spinlock_release(&router->lock); return -1; } - else - { - if (h_val == 0) - { - blr_log_disabled_heartbeat(router); - } - router->heartbeat = h_val; - } } + int r_val = -1; auto& master_connect_retry = change_master.connect_retry; if (!master_connect_retry.empty()) { - int h_val = (int)strtol(master_connect_retry.c_str(), NULL, 10); - if (h_val <= 0 || + r_val = (int)strtol(master_connect_retry.c_str(), NULL, 10); + if (r_val <= 0 || (errno == ERANGE)) { snprintf(error, @@ -4261,18 +4251,28 @@ int blr_handle_change_master(ROUTER_INSTANCE* router, "interval is not valid: %s.", master_connect_retry.c_str()); - blr_abort_change_master(router, - current_master, - error); + MXS_ERROR("%s: %s", router->service->name, error); spinlock_release(&router->lock); return -1; } - else + } + + /* Change the heartbeat */ + if (h_val != -1) + { + if (h_val == 0) { - router->retry_interval = h_val; + blr_log_disabled_heartbeat(router); } + router->heartbeat = h_val; + } + + /* Change the connect retry */ + if (r_val != -1) + { + router->retry_interval = r_val; } /* Change the replication user */