MXS-2329 Use durations in readwritesplit

This commit is contained in:
Johan Wikman
2019-04-29 13:38:32 +03:00
parent ca51316364
commit ea243fd8ba
3 changed files with 55 additions and 25 deletions

View File

@ -504,25 +504,25 @@ extern "C" MXS_MODULE* MXS_CREATE_MODULE()
MXS_MODULE_OPT_NONE,
master_failure_mode_values
},
{"max_slave_replication_lag", MXS_MODULE_PARAM_INT, "-1" },
{"max_slave_connections", MXS_MODULE_PARAM_STRING, MAX_SLAVE_COUNT},
{"retry_failed_reads", MXS_MODULE_PARAM_BOOL, "true" },
{"prune_sescmd_history", MXS_MODULE_PARAM_BOOL, "false" },
{"disable_sescmd_history", MXS_MODULE_PARAM_BOOL, "false" },
{"max_sescmd_history", MXS_MODULE_PARAM_COUNT, "50" },
{"strict_multi_stmt", MXS_MODULE_PARAM_BOOL, "false" },
{"strict_sp_calls", MXS_MODULE_PARAM_BOOL, "false" },
{"master_accept_reads", MXS_MODULE_PARAM_BOOL, "false" },
{"connection_keepalive", MXS_MODULE_PARAM_COUNT, "300" },
{"causal_reads", MXS_MODULE_PARAM_BOOL, "false" },
{"causal_reads_timeout", MXS_MODULE_PARAM_STRING, "10" },
{"master_reconnection", MXS_MODULE_PARAM_BOOL, "false" },
{"delayed_retry", MXS_MODULE_PARAM_BOOL, "false" },
{"delayed_retry_timeout", MXS_MODULE_PARAM_COUNT, "10" },
{"transaction_replay", MXS_MODULE_PARAM_BOOL, "false" },
{"transaction_replay_max_size",MXS_MODULE_PARAM_SIZE, "1Mi" },
{"optimistic_trx", MXS_MODULE_PARAM_BOOL, "false" },
{"lazy_connect", MXS_MODULE_PARAM_BOOL, "false" },
{"max_slave_replication_lag", MXS_MODULE_PARAM_DURATION, "0s", MXS_MODULE_OPT_DURATION_S },
{"max_slave_connections", MXS_MODULE_PARAM_STRING, MAX_SLAVE_COUNT},
{"retry_failed_reads", MXS_MODULE_PARAM_BOOL, "true" },
{"prune_sescmd_history", MXS_MODULE_PARAM_BOOL, "false" },
{"disable_sescmd_history", MXS_MODULE_PARAM_BOOL, "false" },
{"max_sescmd_history", MXS_MODULE_PARAM_COUNT, "50" },
{"strict_multi_stmt", MXS_MODULE_PARAM_BOOL, "false" },
{"strict_sp_calls", MXS_MODULE_PARAM_BOOL, "false" },
{"master_accept_reads", MXS_MODULE_PARAM_BOOL, "false" },
{"connection_keepalive", MXS_MODULE_PARAM_DURATION, "300s", MXS_MODULE_OPT_DURATION_S },
{"causal_reads", MXS_MODULE_PARAM_BOOL, "false" },
{"causal_reads_timeout", MXS_MODULE_PARAM_DURATION, "10s", MXS_MODULE_OPT_DURATION_S },
{"master_reconnection", MXS_MODULE_PARAM_BOOL, "false" },
{"delayed_retry", MXS_MODULE_PARAM_BOOL, "false" },
{"delayed_retry_timeout", MXS_MODULE_PARAM_DURATION, "10s", MXS_MODULE_OPT_DURATION_S },
{"transaction_replay", MXS_MODULE_PARAM_BOOL, "false" },
{"transaction_replay_max_size",MXS_MODULE_PARAM_SIZE, "1Mi" },
{"optimistic_trx", MXS_MODULE_PARAM_BOOL, "false" },
{"lazy_connect", MXS_MODULE_PARAM_BOOL, "false" },
{MXS_END_MODULE_PARAMS}
}
};

View File

@ -130,6 +130,8 @@ static const char gtid_wait_stmt[] =
using BackendSelectFunction = std::function<mxs::PRWBackends::iterator (mxs::PRWBackends& sBackends)>;
BackendSelectFunction get_backend_select_function(select_criteria_t);
using std::chrono::seconds;
struct Config
{
Config(MXS_CONFIG_PARAMETER* params)
@ -147,15 +149,15 @@ struct Config
, strict_multi_stmt(params->get_bool("strict_multi_stmt"))
, strict_sp_calls(params->get_bool("strict_sp_calls"))
, retry_failed_reads(params->get_bool("retry_failed_reads"))
, connection_keepalive(params->get_integer("connection_keepalive"))
, max_slave_replication_lag(params->get_integer("max_slave_replication_lag"))
, connection_keepalive(params->get_duration<seconds>("connection_keepalive").count())
, max_slave_replication_lag(params->get_duration<seconds>("max_slave_replication_lag").count())
, rw_max_slave_conn_percent(0)
, max_slave_connections(0)
, causal_reads(params->get_bool("causal_reads"))
, causal_reads_timeout(params->get_string("causal_reads_timeout"))
, causal_reads_timeout(std::to_string(params->get_duration<seconds>("causal_reads_timeout").count()))
, master_reconnection(params->get_bool("master_reconnection"))
, delayed_retry(params->get_bool("delayed_retry"))
, delayed_retry_timeout(params->get_integer("delayed_retry_timeout"))
, delayed_retry_timeout(params->get_duration<seconds>("delayed_retry_timeout").count())
, transaction_replay(params->get_bool("transaction_replay"))
, trx_max_size(params->get_size("transaction_replay_max_size"))
, optimistic_trx(params->get_bool("optimistic_trx"))