From aa3057695b29cfcd99af887b487585affd88fee6 Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Mon, 29 Apr 2019 13:48:37 +0300 Subject: [PATCH] MXS-2329 Use durations in schema router --- Documentation/Routers/SchemaRouter.md | 7 +++++++ .../routing/schemarouter/schemarouter.cc | 2 +- .../schemarouter/schemarouterinstance.cc | 19 ++++++++++--------- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/Documentation/Routers/SchemaRouter.md b/Documentation/Routers/SchemaRouter.md index 51872ad08..09ab630f3 100644 --- a/Documentation/Routers/SchemaRouter.md +++ b/Documentation/Routers/SchemaRouter.md @@ -200,6 +200,13 @@ change the database i.e. `USE ...` queries. The minimum interval between database map refreshes in seconds. +The interval is 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 intervaltimeout is seconds, a timeout specified in milliseconds will be rejected, +even if the duration is longer than a second. + ## Limitations 1. Cross-database queries (e.g. `SELECT column FROM database1.table UNION select column diff --git a/server/modules/routing/schemarouter/schemarouter.cc b/server/modules/routing/schemarouter/schemarouter.cc index 4ad5f27e5..b996a3311 100644 --- a/server/modules/routing/schemarouter/schemarouter.cc +++ b/server/modules/routing/schemarouter/schemarouter.cc @@ -19,7 +19,7 @@ namespace schemarouter { Config::Config(MXS_CONFIG_PARAMETER* conf) - : refresh_min_interval(conf->get_integer("refresh_interval")) + : refresh_min_interval(conf->get_duration("refresh_interval").count()) , refresh_databases(conf->get_bool("refresh_databases")) , debug(conf->get_bool("debug")) , ignore_regex(conf->get_compiled_regex("ignore_databases_regex", 0, NULL).release()) diff --git a/server/modules/routing/schemarouter/schemarouterinstance.cc b/server/modules/routing/schemarouter/schemarouterinstance.cc index 62d5c8b17..661a458fc 100644 --- a/server/modules/routing/schemarouter/schemarouterinstance.cc +++ b/server/modules/routing/schemarouter/schemarouterinstance.cc @@ -34,7 +34,7 @@ using std::string; namespace schemarouter { -#define DEFAULT_REFRESH_INTERVAL "300" +#define DEFAULT_REFRESH_INTERVAL "300s" /** * @file schemarouter.c The entry points for the simple sharding router module. @@ -294,14 +294,15 @@ extern "C" MXS_MODULE* MXS_CREATE_MODULE() NULL, /* Thread init. */ NULL, /* Thread finish. */ { - {"ignore_databases", MXS_MODULE_PARAM_STRING }, - {"ignore_databases_regex", MXS_MODULE_PARAM_STRING }, - {"max_sescmd_history", MXS_MODULE_PARAM_COUNT, "0"}, - {"disable_sescmd_history", MXS_MODULE_PARAM_BOOL, "false"}, - {"refresh_databases", MXS_MODULE_PARAM_BOOL, "true"}, - {"refresh_interval", MXS_MODULE_PARAM_COUNT, DEFAULT_REFRESH_INTERVAL}, - {"debug", MXS_MODULE_PARAM_BOOL, "false"}, - {"preferred_server", MXS_MODULE_PARAM_SERVER }, + {"ignore_databases", MXS_MODULE_PARAM_STRING }, + {"ignore_databases_regex", MXS_MODULE_PARAM_STRING }, + {"max_sescmd_history", MXS_MODULE_PARAM_COUNT, "0"}, + {"disable_sescmd_history", MXS_MODULE_PARAM_BOOL, "false"}, + {"refresh_databases", MXS_MODULE_PARAM_BOOL, "true"}, + {"refresh_interval", MXS_MODULE_PARAM_DURATION, DEFAULT_REFRESH_INTERVAL, + MXS_MODULE_OPT_DURATION_S }, + {"debug", MXS_MODULE_PARAM_BOOL, "false"}, + {"preferred_server", MXS_MODULE_PARAM_SERVER }, {MXS_END_MODULE_PARAMS} } };