Merge branch '2.1' into 2.2

This commit is contained in:
Markus Mäkelä
2017-09-25 12:32:27 +03:00
16 changed files with 194 additions and 13 deletions

View File

@ -195,6 +195,10 @@ static bool rwsplit_process_router_options(Config& config,
{
config.strict_multi_stmt = config_truth_value(value);
}
else if (strcmp(options[i], "strict_sp_calls") == 0)
{
config.strict_sp_calls = config_truth_value(value);
}
else if (strcmp(options[i], "retry_failed_reads") == 0)
{
config.retry_failed_reads = config_truth_value(value);
@ -966,6 +970,8 @@ static void diagnostics(MXS_ROUTER *instance, DCB *dcb)
router->config().retry_failed_reads ? "true" : "false");
dcb_printf(dcb, "\tstrict_multi_stmt: %s\n",
router->config().strict_multi_stmt ? "true" : "false");
dcb_printf(dcb, "\tstrict_sp_calls: %s\n",
router->config().strict_sp_calls ? "true" : "false");
dcb_printf(dcb, "\tdisable_sescmd_history: %s\n",
router->config().disable_sescmd_history ? "true" : "false");
dcb_printf(dcb, "\tmax_sescmd_history: %lu\n",
@ -1036,6 +1042,8 @@ static json_t* diagnostics_json(const MXS_ROUTER *instance)
json_boolean(router->config().retry_failed_reads));
json_object_set_new(rval, "strict_multi_stmt",
json_boolean(router->config().strict_multi_stmt));
json_object_set_new(rval, "strict_sp_calls",
json_boolean(router->config().strict_sp_calls));
json_object_set_new(rval, "disable_sescmd_history",
json_boolean(router->config().disable_sescmd_history));
json_object_set_new(rval, "max_sescmd_history",
@ -1398,6 +1406,7 @@ MXS_MODULE *MXS_CREATE_MODULE()
{"disable_sescmd_history", MXS_MODULE_PARAM_BOOL, "true"},
{"max_sescmd_history", MXS_MODULE_PARAM_COUNT, "0"},
{"strict_multi_stmt", MXS_MODULE_PARAM_BOOL, "true"},
{"strict_sp_calls", MXS_MODULE_PARAM_BOOL, "false"},
{"master_accept_reads", MXS_MODULE_PARAM_BOOL, "false"},
{"connection_keepalive", MXS_MODULE_PARAM_COUNT, "0"},
{MXS_END_MODULE_PARAMS}

View File

@ -161,6 +161,7 @@ struct Config
disable_sescmd_history(config_get_bool(params, "disable_sescmd_history")),
master_accept_reads(config_get_bool(params, "master_accept_reads")),
strict_multi_stmt(config_get_bool(params, "strict_multi_stmt")),
strict_sp_calls(config_get_bool(params, "strict_sp_calls")),
retry_failed_reads(config_get_bool(params, "retry_failed_reads")),
connection_keepalive(config_get_integer(params, "connection_keepalive")),
max_slave_replication_lag(config_get_integer(params, "max_slave_replication_lag")),
@ -178,6 +179,7 @@ struct Config
bool master_accept_reads; /**< Use master for reads */
bool strict_multi_stmt; /**< Force non-multistatement queries to be routed to
* the master after a multistatement query. */
bool strict_sp_calls; /**< Lock session to master after an SP call */
bool retry_failed_reads; /**< Retry failed reads on other servers */
int connection_keepalive; /**< Send pings to servers that have been idle
* for too long */

View File

@ -118,6 +118,7 @@ bool is_read_tmp_table(RWSplitSession *router_cli_ses,
void check_create_tmp_table(RWSplitSession *router_cli_ses,
GWBUF *querybuf, uint32_t type);
bool check_for_multi_stmt(GWBUF *buf, void *protocol, uint8_t packet_type);
bool check_for_sp_call(GWBUF *buf, uint8_t packet_type);
void close_all_connections(SRWBackendList& backends);

View File

@ -183,7 +183,7 @@ bool route_single_stmt(RWSplit *inst, RWSplitSession *rses, GWBUF *querybuf, con
uint32_t qtype = info.type;
route_target_t route_target = info.target;
bool not_locked_to_master = !rses->large_query &&
(!rses->target_node || rses->target_node != rses->current_master);
(!rses->target_node || rses->target_node != rses->current_master);
if (not_locked_to_master && is_ps_command(command))
{
@ -236,6 +236,7 @@ bool route_single_stmt(RWSplit *inst, RWSplitSession *rses, GWBUF *querybuf, con
succp = handle_master_is_target(inst, rses, &target);
if (!rses->rses_config.strict_multi_stmt &&
!rses->rses_config.strict_sp_calls &&
rses->target_node == rses->current_master)
{
/** Reset the forced node as we're in relaxed multi-statement mode */
@ -774,12 +775,15 @@ handle_multi_temp_and_load(RWSplitSession *rses, GWBUF *querybuf,
* situation, assigning QUERY_TYPE_WRITE for the query will trigger
* the error processing. */
if ((rses->target_node == NULL || rses->target_node != rses->current_master) &&
check_for_multi_stmt(querybuf, rses->client_dcb->protocol, packet_type))
(check_for_multi_stmt(querybuf, rses->client_dcb->protocol, packet_type) ||
check_for_sp_call(querybuf, packet_type)))
{
if (rses->current_master)
{
rses->target_node = rses->current_master;
MXS_INFO("Multi-statement query, routing all future queries to master.");
MXS_INFO("Multi-statement query or stored procedure call, routing "
"all future queries to master.");
}
else
{

View File

@ -224,3 +224,8 @@ bool check_for_multi_stmt(GWBUF *buf, void *protocol, uint8_t packet_type)
return rval;
}
bool check_for_sp_call(GWBUF *buf, uint8_t packet_type)
{
return packet_type == MXS_COM_QUERY && qc_get_operation(buf) == QUERY_OP_CALL;
}