From 0f5972e010a6cf751bc29d9173ba6637c3b468b6 Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Mon, 29 Apr 2019 12:50:33 +0300 Subject: [PATCH] MXS-2329 Use durations with BLR:[heartbeat|connect_retry] --- Documentation/Routers/Binlogrouter.md | 21 ++++++++++++++----- server/modules/routing/binlogrouter/blr.cc | 16 ++++++++------ .../modules/routing/binlogrouter/blr_file.cc | 4 ++-- 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/Documentation/Routers/Binlogrouter.md b/Documentation/Routers/Binlogrouter.md index 7a76ce668..f47a740c2 100644 --- a/Documentation/Routers/Binlogrouter.md +++ b/Documentation/Routers/Binlogrouter.md @@ -173,8 +173,14 @@ it is also possible to use the parameter `passwd`. #### `heartbeat` -This defines the value of the heartbeat interval in seconds for the connection -to the master. The default value for the heartbeat period is every 5 minutes. +This defines the value of the heartbeat interval for the connection +to the master. The duration can be specified as documented +[here](../Getting-Started/Configuration-Guide.md#durations). If no explicit +unit is provided, the value is interpreted as seconds in MaxScale 2.4. In +subsequent versions a value without a unit may be rejected. Note that since +the granularity of the parameter is seconds, a value specified in milliseconds +will be rejected, even if the duration is longer than a second. +The default value for the heartbeat period is every 5 minutes. MariaDB MaxScale requests the master to ensure that a binlog event is sent at least every heartbeat period. If there are no real binlog events to send the @@ -390,9 +396,14 @@ disconnected or not reachable. Default value is 1000. #### `connect_retry` -The option sets the time interval for a new connection retry to master server, -default value is 60 seconds. - +The option sets the time interval for a new connection retry to master server. +The duration can be specified as documented +[here](../Getting-Started/Configuration-Guide.md#durations). If no explicit +unit is provided, the value is interpreted as seconds in MaxScale 2.4. In +subsequent versions a value without a unit may be rejected. Note that since +the granularity of the parameter is seconds, a value specified in milliseconds +will be rejected, even if the duration is longer than a second. +The default value is 60 seconds. **A complete example** of a service entry for a binlog router service would be as follows. diff --git a/server/modules/routing/binlogrouter/blr.cc b/server/modules/routing/binlogrouter/blr.cc index bbd805302..36b73e2c0 100644 --- a/server/modules/routing/binlogrouter/blr.cc +++ b/server/modules/routing/binlogrouter/blr.cc @@ -211,10 +211,14 @@ extern "C" MXS_MODULE* MXS_CREATE_MODULE() DEF_LONG_BURST}, {"burstsize", MXS_MODULE_PARAM_SIZE, DEF_BURST_SIZE}, - {"heartbeat", MXS_MODULE_PARAM_COUNT, - BLR_HEARTBEAT_DEFAULT_INTERVAL}, - {"connect_retry", MXS_MODULE_PARAM_COUNT, - BLR_MASTER_CONNECT_RETRY}, + {"heartbeat", MXS_MODULE_PARAM_DURATION, + BLR_HEARTBEAT_DEFAULT_INTERVAL "s", + MXS_MODULE_OPT_DURATION_S + }, + {"connect_retry", MXS_MODULE_PARAM_DURATION, + BLR_MASTER_CONNECT_RETRY "s", + MXS_MODULE_OPT_DURATION_S + }, {"master_retry_count", MXS_MODULE_PARAM_COUNT, BLR_MASTER_RETRY_COUNT}, {"send_slave_heartbeat", MXS_MODULE_PARAM_BOOL, @@ -345,8 +349,8 @@ static MXS_ROUTER* createInstance(SERVICE* service, MXS_CONFIG_PARAMETER* params inst->long_burst = params->get_integer("longburst"); inst->burst_size = params->get_size("burstsize"); inst->binlogdir = params->get_c_str_copy("binlogdir"); - inst->heartbeat = params->get_integer("heartbeat"); - inst->retry_interval = params->get_integer("connect_retry"); + inst->heartbeat = params->get_duration("heartbeat").count(); + inst->retry_interval = params->get_duration("connect_retry").count(); inst->retry_limit = params->get_integer("master_retry_count"); inst->ssl_cert_verification_depth = params->get_integer("ssl_cert_verification_depth"); inst->mariadb10_compat = params->get_bool("mariadb10-compatibility"); diff --git a/server/modules/routing/binlogrouter/blr_file.cc b/server/modules/routing/binlogrouter/blr_file.cc index 112e2e77a..c28093c9b 100644 --- a/server/modules/routing/binlogrouter/blr_file.cc +++ b/server/modules/routing/binlogrouter/blr_file.cc @@ -3383,8 +3383,8 @@ void write_master_config(FILE* config_file, const ChangeMasterConfig& config) fprintf(config_file, "master_tls_version=%s\n", config.ssl_version.c_str()); } - fprintf(config_file, "master_heartbeat_period=%d\n", config.heartbeat_period); - fprintf(config_file, "master_connect_retry=%d\n", config.connect_retry); + fprintf(config_file, "master_heartbeat_period=%ds\n", config.heartbeat_period); + fprintf(config_file, "master_connect_retry=%ds\n", config.connect_retry); } }