Merge remote-tracking branch 'origin/develop' into MXS-329-develop-20151111
# Conflicts: # server/core/CMakeLists.txt # server/core/buffer.c # server/core/service.c # server/modules/filter/tee.c # server/modules/monitor/mysql_mon.c # server/modules/routing/binlog/blr.c # server/modules/routing/binlog/blr_slave.c # server/modules/routing/debugcmd.c # server/modules/routing/readwritesplit/readwritesplit.c # utils/skygw_utils.cc - resolved.
This commit is contained in:
@ -47,10 +47,6 @@ MODULE_INFO info = {
|
||||
|
||||
#define RWSPLIT_TRACE_MSG_LEN 1000
|
||||
|
||||
/** Defined in log_manager.cc */
|
||||
extern int lm_enabled_logfiles_bitmask;
|
||||
extern size_t log_ses_count[];
|
||||
extern __thread log_info_t tls_log_info;
|
||||
/**
|
||||
* @file readwritesplit.c The entry points for the read/write query splitting
|
||||
* router module.
|
||||
@ -109,6 +105,7 @@ static DCB* rses_get_client_dcb(ROUTER_CLIENT_SES* rses);
|
||||
static route_target_t get_route_target (
|
||||
skygw_query_type_t qtype,
|
||||
bool trx_active,
|
||||
bool load_active,
|
||||
target_t use_sql_variables_in,
|
||||
HINT* hint);
|
||||
|
||||
@ -1373,6 +1370,7 @@ static backend_ref_t* check_candidate_bref(
|
||||
static route_target_t get_route_target (
|
||||
skygw_query_type_t qtype,
|
||||
bool trx_active,
|
||||
bool load_active,
|
||||
target_t use_sql_variables_in,
|
||||
HINT* hint)
|
||||
{
|
||||
@ -1380,13 +1378,15 @@ static route_target_t get_route_target (
|
||||
/**
|
||||
* These queries are not affected by hints
|
||||
*/
|
||||
if (QUERY_IS_TYPE(qtype, QUERY_TYPE_SESSION_WRITE) ||
|
||||
if (!load_active && (QUERY_IS_TYPE(qtype, QUERY_TYPE_SESSION_WRITE) ||
|
||||
QUERY_IS_TYPE(qtype, QUERY_TYPE_PREPARE_STMT) ||
|
||||
QUERY_IS_TYPE(qtype, QUERY_TYPE_PREPARE_NAMED_STMT) ||
|
||||
/** Configured to allow writing variables to all nodes */
|
||||
(use_sql_variables_in == TYPE_ALL &&
|
||||
QUERY_IS_TYPE(qtype, QUERY_TYPE_GSYSVAR_WRITE)) ||
|
||||
/** enable or disable autocommit are always routed to all */
|
||||
QUERY_IS_TYPE(qtype, QUERY_TYPE_ENABLE_AUTOCOMMIT) ||
|
||||
QUERY_IS_TYPE(qtype, QUERY_TYPE_DISABLE_AUTOCOMMIT))
|
||||
QUERY_IS_TYPE(qtype, QUERY_TYPE_DISABLE_AUTOCOMMIT)))
|
||||
{
|
||||
/**
|
||||
* This is problematic query because it would be routed to all
|
||||
@ -1424,7 +1424,7 @@ static route_target_t get_route_target (
|
||||
/**
|
||||
* Hints may affect on routing of the following queries
|
||||
*/
|
||||
else if (!trx_active &&
|
||||
else if (!trx_active && !load_active &&
|
||||
(QUERY_IS_TYPE(qtype, QUERY_TYPE_READ) || /*< any SELECT */
|
||||
QUERY_IS_TYPE(qtype, QUERY_TYPE_SHOW_TABLES) || /*< 'SHOW TABLES' */
|
||||
QUERY_IS_TYPE(qtype, QUERY_TYPE_USERVAR_READ)|| /*< read user var */
|
||||
@ -2148,8 +2148,13 @@ static bool route_single_stmt(
|
||||
|
||||
if(packet_len == 0)
|
||||
{
|
||||
/** Empty packet signals end of LOAD DATA LOCAL INFILE, send it to master*/
|
||||
route_target = TARGET_MASTER;
|
||||
packet_type = MYSQL_COM_UNDEFINED;
|
||||
rses->rses_load_active = false;
|
||||
route_target = TARGET_MASTER;
|
||||
skygw_log_write_flush(LT, "> LOAD DATA LOCAL INFILE finished: "
|
||||
"%lu bytes sent.", rses->rses_load_data_sent + gwbuf_length(querybuf));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2199,17 +2204,36 @@ static bool route_single_stmt(
|
||||
break;
|
||||
} /**< switch by packet type */
|
||||
|
||||
/**
|
||||
* Check if the query has anything to do with temporary tables.
|
||||
*/
|
||||
if (!rses_begin_locked_router_action(rses))
|
||||
{
|
||||
succp = false;
|
||||
goto retblock;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Check if the query has anything to do with temporary tables.
|
||||
*/
|
||||
qtype = is_read_tmp_table(rses, querybuf, qtype);
|
||||
check_create_tmp_table(rses, querybuf, qtype);
|
||||
check_drop_tmp_table(rses, querybuf,qtype);
|
||||
|
||||
/**
|
||||
* Check if this is a LOAD DATA LOCAL INFILE query. If so, send all queries
|
||||
* to the master until the last, empty packet arrives.
|
||||
*/
|
||||
if (!rses->rses_load_active)
|
||||
{
|
||||
skygw_query_op_t queryop = query_classifier_get_operation(querybuf);
|
||||
if (queryop == QUERY_OP_LOAD)
|
||||
{
|
||||
rses->rses_load_active = true;
|
||||
rses->rses_load_data_sent = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rses->rses_load_data_sent += gwbuf_length(querybuf);
|
||||
}
|
||||
|
||||
rses_end_locked_router_action(rses);
|
||||
/**
|
||||
* If autocommit is disabled or transaction is explicitly started
|
||||
@ -2250,28 +2274,35 @@ static bool route_single_stmt(
|
||||
|
||||
if (LOG_IS_ENABLED(LOGFILE_TRACE))
|
||||
{
|
||||
uint8_t* packet = GWBUF_DATA(querybuf);
|
||||
unsigned char ptype = packet[4];
|
||||
size_t len = MIN(GWBUF_LENGTH(querybuf),
|
||||
MYSQL_GET_PACKET_LEN((unsigned char *)querybuf->start)-1);
|
||||
char* data = (char*)&packet[5];
|
||||
char* contentstr = strndup(data, MIN(len, RWSPLIT_TRACE_MSG_LEN));
|
||||
char* qtypestr = skygw_get_qtype_str(qtype);
|
||||
|
||||
skygw_log_write(
|
||||
LOGFILE_TRACE,
|
||||
"> Autocommit: %s, trx is %s, cmd: %s, type: %s, "
|
||||
"stmt: %s%s %s",
|
||||
(rses->rses_autocommit_enabled ? "[enabled]" : "[disabled]"),
|
||||
(rses->rses_transaction_active ? "[open]" : "[not open]"),
|
||||
STRPACKETTYPE(ptype),
|
||||
(qtypestr==NULL ? "N/A" : qtypestr),
|
||||
contentstr,
|
||||
(querybuf->hint == NULL ? "" : ", Hint:"),
|
||||
(querybuf->hint == NULL ? "" : STRHINTTYPE(querybuf->hint->type)));
|
||||
|
||||
free(contentstr);
|
||||
free(qtypestr);
|
||||
if (!rses->rses_load_active)
|
||||
{
|
||||
uint8_t* packet = GWBUF_DATA(querybuf);
|
||||
unsigned char ptype = packet[4];
|
||||
size_t len = MIN(GWBUF_LENGTH(querybuf),
|
||||
MYSQL_GET_PACKET_LEN((unsigned char *)querybuf->start) - 1);
|
||||
char* data = (char*) &packet[5];
|
||||
char* contentstr = strndup(data, MIN(len, RWSPLIT_TRACE_MSG_LEN));
|
||||
char* qtypestr = skygw_get_qtype_str(qtype);
|
||||
|
||||
skygw_log_write(LOGFILE_TRACE,
|
||||
"> Autocommit: %s, trx is %s, cmd: %s, type: %s, "
|
||||
"stmt: %s%s %s",
|
||||
(rses->rses_autocommit_enabled ? "[enabled]" : "[disabled]"),
|
||||
(rses->rses_transaction_active ? "[open]" : "[not open]"),
|
||||
STRPACKETTYPE(ptype),
|
||||
(qtypestr == NULL ? "N/A" : qtypestr),
|
||||
contentstr,
|
||||
(querybuf->hint == NULL ? "" : ", Hint:"),
|
||||
(querybuf->hint == NULL ? "" : STRHINTTYPE(querybuf->hint->type)));
|
||||
|
||||
free(contentstr);
|
||||
free(qtypestr);
|
||||
}
|
||||
else
|
||||
{
|
||||
skygw_log_write(LT, "> Processing LOAD DATA LOCAL INFILE: "
|
||||
"%lu bytes sent.", rses->rses_load_data_sent);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Find out where to route the query. Result may not be clear; it is
|
||||
@ -2292,9 +2323,10 @@ static bool route_single_stmt(
|
||||
*/
|
||||
route_target = get_route_target(qtype,
|
||||
rses->rses_transaction_active,
|
||||
rses->rses_load_active,
|
||||
rses->rses_config.rw_use_sql_variables_in,
|
||||
querybuf->hint);
|
||||
|
||||
|
||||
if (TARGET_IS_ALL(route_target))
|
||||
{
|
||||
/** Multiple, conflicting routing target. Return error */
|
||||
@ -4549,7 +4581,7 @@ static bool route_session_write(
|
||||
if (router_cli_ses->rses_config.rw_max_sescmd_history_size > 0 &&
|
||||
router_cli_ses->rses_nsescmd >= router_cli_ses->rses_config.rw_max_sescmd_history_size)
|
||||
{
|
||||
skygw_log_write(LE, "Warning: Router session exceeded session command history limit. "
|
||||
skygw_log_write(LM, "Warning: Router session exceeded session command history limit. "
|
||||
"Slave recovery is disabled and only slave servers with consistent session state are used "
|
||||
"for the duration of the session.");
|
||||
router_cli_ses->rses_config.rw_disable_sescmd_hist = true;
|
||||
|
Reference in New Issue
Block a user