Replaced RWSplit parameters write_ses_variables_to_all and read_ses_variables_from_slaves with
use_sql_variables_in=[master|all] (default all) Modified MaxScale Configuration And Usage Scenarios-Z3.pdf and MaxScale_template.cnf accordingly. Fixed typo in server/modules/routing/readwritesplit/test/rwsplit.sh
This commit is contained in:
Binary file not shown.
@ -51,9 +51,8 @@ passwd=maxpwd
|
|||||||
# enable_root_user=<0 or 1, default is 0>
|
# enable_root_user=<0 or 1, default is 0>
|
||||||
# version_string=<specific string for server handshake,
|
# version_string=<specific string for server handshake,
|
||||||
# default is the MariaDB embedded library version>
|
# default is the MariaDB embedded library version>
|
||||||
#
|
#
|
||||||
# read_ses_variables_from_slaves=<Y|N> Default is Yes
|
# use_sql_variables_in=[master|all] (default all)
|
||||||
# write_ses_variables_to_all=<Y|(N)> Default is No
|
|
||||||
# router_options=<option[=value]>,<option[=value]>,...
|
# router_options=<option[=value]>,<option[=value]>,...
|
||||||
# where value=[master|slave|synced]
|
# where value=[master|slave|synced]
|
||||||
#
|
#
|
||||||
@ -72,8 +71,7 @@ router=readwritesplit
|
|||||||
servers=server1,server2,server3
|
servers=server1,server2,server3
|
||||||
user=maxuser
|
user=maxuser
|
||||||
passwd=maxpwd
|
passwd=maxpwd
|
||||||
read_ses_variables_from_slaves=No
|
use_sql_variables_in=all
|
||||||
write_ses_variables_to_all=Yes
|
|
||||||
max_slave_connections=50%
|
max_slave_connections=50%
|
||||||
max_slave_replication_lag=30
|
max_slave_replication_lag=30
|
||||||
router_options=slave_selection_criteria=LEAST_BEHIND_MASTER
|
router_options=slave_selection_criteria=LEAST_BEHIND_MASTER
|
||||||
|
@ -333,13 +333,20 @@ int error_count = 0;
|
|||||||
param = config_get_param(obj->parameters,
|
param = config_get_param(obj->parameters,
|
||||||
"max_slave_connections");
|
"max_slave_connections");
|
||||||
|
|
||||||
succp = service_set_param_value(
|
if (param == NULL)
|
||||||
obj->element,
|
{
|
||||||
param,
|
succp = false;
|
||||||
max_slave_conn_str,
|
}
|
||||||
COUNT_ATMOST,
|
else
|
||||||
(COUNT_TYPE|PERCENT_TYPE));
|
{
|
||||||
|
succp = service_set_param_value(
|
||||||
|
obj->element,
|
||||||
|
param,
|
||||||
|
max_slave_conn_str,
|
||||||
|
COUNT_ATMOST,
|
||||||
|
(COUNT_TYPE|PERCENT_TYPE));
|
||||||
|
}
|
||||||
|
|
||||||
if (!succp)
|
if (!succp)
|
||||||
{
|
{
|
||||||
LOGIF(LM, (skygw_log_write(
|
LOGIF(LM, (skygw_log_write(
|
||||||
@ -365,13 +372,20 @@ int error_count = 0;
|
|||||||
obj->parameters,
|
obj->parameters,
|
||||||
"max_slave_replication_lag");
|
"max_slave_replication_lag");
|
||||||
|
|
||||||
succp = service_set_param_value(
|
if (param == NULL)
|
||||||
obj->element,
|
{
|
||||||
param,
|
succp = false;
|
||||||
max_slave_rlag_str,
|
}
|
||||||
COUNT_ATMOST,
|
else
|
||||||
COUNT_TYPE);
|
{
|
||||||
|
succp = service_set_param_value(
|
||||||
|
obj->element,
|
||||||
|
param,
|
||||||
|
max_slave_rlag_str,
|
||||||
|
COUNT_ATMOST,
|
||||||
|
COUNT_TYPE);
|
||||||
|
}
|
||||||
|
|
||||||
if (!succp)
|
if (!succp)
|
||||||
{
|
{
|
||||||
LOGIF(LM, (skygw_log_write(
|
LOGIF(LM, (skygw_log_write(
|
||||||
@ -389,60 +403,40 @@ int error_count = 0;
|
|||||||
if (is_rwsplit)
|
if (is_rwsplit)
|
||||||
{
|
{
|
||||||
CONFIG_PARAMETER* param;
|
CONFIG_PARAMETER* param;
|
||||||
char* write_sesvars_to_all;
|
char* use_sql_variables_in;
|
||||||
char* read_sesvars_from_slaves;
|
|
||||||
bool succp;
|
bool succp;
|
||||||
|
|
||||||
write_sesvars_to_all =
|
use_sql_variables_in =
|
||||||
config_get_value(obj->parameters,
|
config_get_value(obj->parameters,
|
||||||
"write_ses_variables_to_all");
|
"use_sql_variables_in");
|
||||||
|
|
||||||
if (write_sesvars_to_all != NULL)
|
if (use_sql_variables_in != NULL)
|
||||||
{
|
{
|
||||||
param = config_get_param(
|
param = config_get_param(
|
||||||
obj->parameters,
|
obj->parameters,
|
||||||
"write_ses_variables_to_all");
|
"use_sql_variables_in");
|
||||||
succp = service_set_param_value(obj->element,
|
|
||||||
param,
|
if (param == NULL)
|
||||||
write_sesvars_to_all,
|
|
||||||
COUNT_NONE,
|
|
||||||
BOOL_TYPE);
|
|
||||||
if (!succp)
|
|
||||||
{
|
{
|
||||||
LOGIF(LM, (skygw_log_write(
|
succp = false;
|
||||||
LOGFILE_MESSAGE,
|
|
||||||
"* Warning : invalid value type "
|
|
||||||
"for parameter \'%s.%s = %s\'\n\tExpected "
|
|
||||||
"type is <true/false> for write session "
|
|
||||||
"variables to all backends.",
|
|
||||||
((SERVICE*)obj->element)->name,
|
|
||||||
param->name,
|
|
||||||
param->value)));
|
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
read_sesvars_from_slaves =
|
{
|
||||||
config_get_value(
|
succp = service_set_param_value(obj->element,
|
||||||
obj->parameters,
|
param,
|
||||||
"read_ses_variables_from_slaves");
|
use_sql_variables_in,
|
||||||
|
COUNT_NONE,
|
||||||
if (read_sesvars_from_slaves != NULL)
|
SQLVAR_TARGET_TYPE);
|
||||||
{
|
}
|
||||||
param = config_get_param(
|
|
||||||
obj->parameters,
|
|
||||||
"read_ses_variables_from_slaves");
|
|
||||||
succp = service_set_param_value(obj->element,
|
|
||||||
param,
|
|
||||||
read_sesvars_from_slaves,
|
|
||||||
COUNT_NONE,
|
|
||||||
BOOL_TYPE);
|
|
||||||
if (!succp)
|
if (!succp)
|
||||||
{
|
{
|
||||||
LOGIF(LM, (skygw_log_write(
|
LOGIF(LM, (skygw_log_write(
|
||||||
LOGFILE_MESSAGE,
|
LOGFILE_MESSAGE,
|
||||||
"* Warning : invalid value type "
|
"* Warning : invalid value type "
|
||||||
"for parameter \'%s.%s = %s\'\n\tExpected "
|
"for parameter \'%s.%s = %s\'\n\tExpected "
|
||||||
"type is <true/false> for write session "
|
"type is [master|all] for "
|
||||||
"variables to all backends.",
|
"use sql variables in.",
|
||||||
((SERVICE*)obj->element)->name,
|
((SERVICE*)obj->element)->name,
|
||||||
param->name,
|
param->name,
|
||||||
param->value)));
|
param->value)));
|
||||||
@ -896,7 +890,7 @@ bool config_get_valint(
|
|||||||
{
|
{
|
||||||
bool succp = false;;
|
bool succp = false;;
|
||||||
|
|
||||||
ss_dassert(ptype == COUNT_TYPE || ptype == PERCENT_TYPE);
|
ss_dassert((ptype == COUNT_TYPE || ptype == PERCENT_TYPE) && param != NULL);
|
||||||
|
|
||||||
while (param)
|
while (param)
|
||||||
{
|
{
|
||||||
@ -933,8 +927,9 @@ bool config_get_valbool(
|
|||||||
bool succp;
|
bool succp;
|
||||||
|
|
||||||
ss_dassert(ptype == BOOL_TYPE);
|
ss_dassert(ptype == BOOL_TYPE);
|
||||||
|
ss_dassert(param != NULL);
|
||||||
|
|
||||||
if (ptype != BOOL_TYPE)
|
if (ptype != BOOL_TYPE || param == NULL)
|
||||||
{
|
{
|
||||||
succp = false;
|
succp = false;
|
||||||
goto return_succp;
|
goto return_succp;
|
||||||
@ -958,6 +953,40 @@ return_succp:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool config_get_valtarget(
|
||||||
|
target_t* val,
|
||||||
|
CONFIG_PARAMETER* param,
|
||||||
|
const char* name,
|
||||||
|
config_param_type_t ptype)
|
||||||
|
{
|
||||||
|
bool succp;
|
||||||
|
|
||||||
|
ss_dassert(ptype == SQLVAR_TARGET_TYPE);
|
||||||
|
ss_dassert(param != NULL);
|
||||||
|
|
||||||
|
if (ptype != SQLVAR_TARGET_TYPE || param == NULL)
|
||||||
|
{
|
||||||
|
succp = false;
|
||||||
|
goto return_succp;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (param)
|
||||||
|
{
|
||||||
|
if (name == NULL || !strncmp(param->name, name, MAX_PARAM_LEN))
|
||||||
|
{
|
||||||
|
*val = param->qfd.valtarget;
|
||||||
|
succp = true;
|
||||||
|
goto return_succp;
|
||||||
|
}
|
||||||
|
param = param->next;
|
||||||
|
}
|
||||||
|
succp = false;
|
||||||
|
|
||||||
|
return_succp:
|
||||||
|
return succp;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
CONFIG_PARAMETER* config_clone_param(
|
CONFIG_PARAMETER* config_clone_param(
|
||||||
CONFIG_PARAMETER* param)
|
CONFIG_PARAMETER* param)
|
||||||
{
|
{
|
||||||
@ -1135,13 +1164,20 @@ SERVER *server;
|
|||||||
param = config_get_param(obj->parameters,
|
param = config_get_param(obj->parameters,
|
||||||
"max_slave_connections");
|
"max_slave_connections");
|
||||||
|
|
||||||
succp = service_set_param_value(
|
if (param == NULL)
|
||||||
service,
|
{
|
||||||
param,
|
succp = false;
|
||||||
max_slave_conn_str,
|
}
|
||||||
COUNT_ATMOST,
|
else
|
||||||
(PERCENT_TYPE|COUNT_TYPE));
|
{
|
||||||
|
succp = service_set_param_value(
|
||||||
|
service,
|
||||||
|
param,
|
||||||
|
max_slave_conn_str,
|
||||||
|
COUNT_ATMOST,
|
||||||
|
(PERCENT_TYPE|COUNT_TYPE));
|
||||||
|
}
|
||||||
|
|
||||||
if (!succp)
|
if (!succp)
|
||||||
{
|
{
|
||||||
LOGIF(LM, (skygw_log_write(
|
LOGIF(LM, (skygw_log_write(
|
||||||
@ -1171,13 +1207,20 @@ SERVER *server;
|
|||||||
obj->parameters,
|
obj->parameters,
|
||||||
"max_slave_replication_lag");
|
"max_slave_replication_lag");
|
||||||
|
|
||||||
succp = service_set_param_value(
|
if (param == NULL)
|
||||||
service,
|
{
|
||||||
param,
|
succp = false;
|
||||||
max_slave_rlag_str,
|
}
|
||||||
COUNT_ATMOST,
|
else
|
||||||
COUNT_TYPE);
|
{
|
||||||
|
succp = service_set_param_value(
|
||||||
|
service,
|
||||||
|
param,
|
||||||
|
max_slave_rlag_str,
|
||||||
|
COUNT_ATMOST,
|
||||||
|
COUNT_TYPE);
|
||||||
|
}
|
||||||
|
|
||||||
if (!succp)
|
if (!succp)
|
||||||
{
|
{
|
||||||
LOGIF(LM, (skygw_log_write(
|
LOGIF(LM, (skygw_log_write(
|
||||||
@ -1426,8 +1469,7 @@ static char *service_params[] =
|
|||||||
"enable_root_user",
|
"enable_root_user",
|
||||||
"max_slave_connections",
|
"max_slave_connections",
|
||||||
"max_slave_replication_lag",
|
"max_slave_replication_lag",
|
||||||
"write_ses_variables_to_all", /*< rwsplit only */
|
"use_sql_variables_in", /*< rwsplit only */
|
||||||
"read_ses_variables_from_slaves", /*< rwsplit only */
|
|
||||||
"version_string",
|
"version_string",
|
||||||
"filters",
|
"filters",
|
||||||
NULL
|
NULL
|
||||||
@ -1551,7 +1593,11 @@ bool config_set_qualified_param(
|
|||||||
param->qfd.valbool = *(bool *)val;
|
param->qfd.valbool = *(bool *)val;
|
||||||
succp = true;
|
succp = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case SQLVAR_TARGET_TYPE:
|
||||||
|
param->qfd.valtarget = *(target_t *)val;
|
||||||
|
succp = true;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
succp = false;
|
succp = false;
|
||||||
break;
|
break;
|
||||||
|
@ -61,9 +61,17 @@ typedef struct typelib_st {
|
|||||||
const char* tl_name;
|
const char* tl_name;
|
||||||
const char** tl_p_elems;
|
const char** tl_p_elems;
|
||||||
} typelib_t;
|
} typelib_t;
|
||||||
|
/** Set of subsequent false,true pairs */
|
||||||
|
static const char* bool_strings[11] = {"FALSE", "TRUE", "OFF", "ON", "N", "Y", "0", "1", "NO", "YES", 0};
|
||||||
|
typelib_t bool_type = {array_nelems(bool_strings)-1, "bool_type", bool_strings};
|
||||||
|
|
||||||
static const char* bool_strings[11]= {"FALSE", "TRUE", "OFF", "ON", "N", "Y", "0", "1", "NO", "YES", 0};
|
/** List of valid values */
|
||||||
typelib_t bool_type = {array_nelems(bool_strings)-1, "bool_type", bool_strings};
|
static const char* sqlvar_target_strings[4] = {"MASTER", "ALL", 0};
|
||||||
|
typelib_t sqlvar_target_type = {
|
||||||
|
array_nelems(sqlvar_target_strings)-1,
|
||||||
|
"sqlvar_target_type",
|
||||||
|
sqlvar_target_strings
|
||||||
|
};
|
||||||
|
|
||||||
static SPINLOCK service_spin = SPINLOCK_INIT;
|
static SPINLOCK service_spin = SPINLOCK_INIT;
|
||||||
static SERVICE *allServices = NULL;
|
static SERVICE *allServices = NULL;
|
||||||
@ -1019,10 +1027,11 @@ bool service_set_param_value (
|
|||||||
count_spec_t count_spec,
|
count_spec_t count_spec,
|
||||||
config_param_type_t type)
|
config_param_type_t type)
|
||||||
{
|
{
|
||||||
char* p;
|
char* p;
|
||||||
int valint;
|
int valint;
|
||||||
bool valbool;
|
bool valbool;
|
||||||
bool succp = true;
|
target_t valtarget;
|
||||||
|
bool succp = true;
|
||||||
|
|
||||||
if (PARAM_IS_TYPE(type,PERCENT_TYPE) ||PARAM_IS_TYPE(type,COUNT_TYPE))
|
if (PARAM_IS_TYPE(type,PERCENT_TYPE) ||PARAM_IS_TYPE(type,COUNT_TYPE))
|
||||||
{
|
{
|
||||||
@ -1111,6 +1120,34 @@ bool service_set_param_value (
|
|||||||
succp = false;
|
succp = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (type == SQLVAR_TARGET_TYPE)
|
||||||
|
{
|
||||||
|
unsigned int rc;
|
||||||
|
|
||||||
|
rc = find_type(&sqlvar_target_type, valstr, strlen(valstr)+1);
|
||||||
|
|
||||||
|
if (rc > 0 && rc < 3)
|
||||||
|
{
|
||||||
|
succp = true;
|
||||||
|
if (rc == 1)
|
||||||
|
{
|
||||||
|
valtarget = TYPE_MASTER;
|
||||||
|
}
|
||||||
|
else if (rc == 2)
|
||||||
|
{
|
||||||
|
valtarget = TYPE_ALL;
|
||||||
|
}
|
||||||
|
/** add param to config */
|
||||||
|
config_set_qualified_param(param,
|
||||||
|
(void *)&valtarget,
|
||||||
|
SQLVAR_TARGET_TYPE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
succp = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (succp)
|
if (succp)
|
||||||
{
|
{
|
||||||
service_add_qualified_param(service, param); /*< add param to svc */
|
service_add_qualified_param(service, param); /*< add param to svc */
|
||||||
|
@ -39,13 +39,20 @@
|
|||||||
enum {MAX_PARAM_LEN=256};
|
enum {MAX_PARAM_LEN=256};
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
UNDEFINED_TYPE = 0x00,
|
UNDEFINED_TYPE = 0x00,
|
||||||
STRING_TYPE = 0x01,
|
STRING_TYPE = 0x01,
|
||||||
COUNT_TYPE = 0x02,
|
COUNT_TYPE = 0x02,
|
||||||
PERCENT_TYPE = 0x04,
|
PERCENT_TYPE = 0x04,
|
||||||
BOOL_TYPE = 0x08
|
BOOL_TYPE = 0x08,
|
||||||
|
SQLVAR_TARGET_TYPE = 0x10
|
||||||
} config_param_type_t;
|
} config_param_type_t;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
TYPE_UNDEFINED = 0,
|
||||||
|
TYPE_MASTER,
|
||||||
|
TYPE_ALL
|
||||||
|
} target_t;
|
||||||
|
|
||||||
enum {MAX_RLAG_NOT_AVAILABLE=-1, MAX_RLAG_UNDEFINED=-2};
|
enum {MAX_RLAG_NOT_AVAILABLE=-1, MAX_RLAG_UNDEFINED=-2};
|
||||||
|
|
||||||
#define PARAM_IS_TYPE(p,t) ((p) & (t))
|
#define PARAM_IS_TYPE(p,t) ((p) & (t))
|
||||||
@ -61,6 +68,7 @@ typedef struct config_parameter {
|
|||||||
int valcount; /*< int */
|
int valcount; /*< int */
|
||||||
int valpercent; /*< int */
|
int valpercent; /*< int */
|
||||||
bool valbool; /*< bool */
|
bool valbool; /*< bool */
|
||||||
|
target_t valtarget; /*< sql variable route target */
|
||||||
} qfd;
|
} qfd;
|
||||||
config_param_type_t qfd_param_type;
|
config_param_type_t qfd_param_type;
|
||||||
struct config_parameter *next; /**< Next pointer in the linked list */
|
struct config_parameter *next; /**< Next pointer in the linked list */
|
||||||
@ -111,4 +119,9 @@ bool config_get_valbool(
|
|||||||
const char* name, /*< if NULL examine current param only */
|
const char* name, /*< if NULL examine current param only */
|
||||||
config_param_type_t ptype);
|
config_param_type_t ptype);
|
||||||
|
|
||||||
|
bool config_get_valtarget(
|
||||||
|
target_t* val,
|
||||||
|
CONFIG_PARAMETER* param,
|
||||||
|
const char* name, /*< if NULL examine current param only */
|
||||||
|
config_param_type_t ptype);
|
||||||
#endif
|
#endif
|
||||||
|
@ -118,8 +118,7 @@ typedef enum select_criteria {
|
|||||||
/** default values for rwsplit configuration parameters */
|
/** default values for rwsplit configuration parameters */
|
||||||
#define CONFIG_MAX_SLAVE_CONN 1
|
#define CONFIG_MAX_SLAVE_CONN 1
|
||||||
#define CONFIG_MAX_SLAVE_RLAG -1 /*< not used */
|
#define CONFIG_MAX_SLAVE_RLAG -1 /*< not used */
|
||||||
#define CONFIG_READ_SESVARS_FROM_SLAVES false
|
#define CONFIG_SQL_VARIABLES_IN TYPE_ALL
|
||||||
#define CONFIG_WRITE_SESVARS_TO_ALL true
|
|
||||||
|
|
||||||
#define GET_SELECT_CRITERIA(s) \
|
#define GET_SELECT_CRITERIA(s) \
|
||||||
(strncmp(s,"LEAST_GLOBAL_CONNECTIONS", strlen("LEAST_GLOBAL_CONNECTIONS")) == 0 ? \
|
(strncmp(s,"LEAST_GLOBAL_CONNECTIONS", strlen("LEAST_GLOBAL_CONNECTIONS")) == 0 ? \
|
||||||
@ -234,9 +233,7 @@ typedef struct rwsplit_config_st {
|
|||||||
int rw_max_slave_conn_count;
|
int rw_max_slave_conn_count;
|
||||||
select_criteria_t rw_slave_select_criteria;
|
select_criteria_t rw_slave_select_criteria;
|
||||||
int rw_max_slave_replication_lag;
|
int rw_max_slave_replication_lag;
|
||||||
/** Route user- & system variable writes to all backends */
|
target_t rw_use_sql_variables_in;
|
||||||
bool rw_write_sesvars_to_all;
|
|
||||||
/** Route queries including user- & system variables to slaves */
|
|
||||||
bool rw_read_sesvars_from_slaves;
|
bool rw_read_sesvars_from_slaves;
|
||||||
|
|
||||||
} rwsplit_config_t;
|
} rwsplit_config_t;
|
||||||
|
@ -99,11 +99,10 @@ static int rses_get_max_replication_lag(ROUTER_CLIENT_SES* rses);
|
|||||||
static backend_ref_t* get_bref_from_dcb(ROUTER_CLIENT_SES* rses, DCB* dcb);
|
static backend_ref_t* get_bref_from_dcb(ROUTER_CLIENT_SES* rses, DCB* dcb);
|
||||||
|
|
||||||
static route_target_t get_route_target (
|
static route_target_t get_route_target (
|
||||||
skygw_query_type_t qtype,
|
skygw_query_type_t qtype,
|
||||||
bool read_sesvars_from_slaves,
|
bool trx_active,
|
||||||
bool write_sesvars_to_all,
|
target_t use_sql_variables_in,
|
||||||
bool trx_active,
|
HINT* hint);
|
||||||
HINT* hint);
|
|
||||||
|
|
||||||
static uint8_t getCapabilities (ROUTER* inst, void* router_session);
|
static uint8_t getCapabilities (ROUTER* inst, void* router_session);
|
||||||
|
|
||||||
@ -383,6 +382,11 @@ static void refreshInstance(
|
|||||||
|
|
||||||
while (param != NULL)
|
while (param != NULL)
|
||||||
{
|
{
|
||||||
|
/** Catch unused parameter types */
|
||||||
|
ss_dassert(paramtype == COUNT_TYPE ||
|
||||||
|
paramtype == PERCENT_TYPE ||
|
||||||
|
paramtype == SQLVAR_TARGET_TYPE);
|
||||||
|
|
||||||
if (paramtype == COUNT_TYPE)
|
if (paramtype == COUNT_TYPE)
|
||||||
{
|
{
|
||||||
if (strncmp(param->name, "max_slave_connections", MAX_PARAM_LEN) == 0)
|
if (strncmp(param->name, "max_slave_connections", MAX_PARAM_LEN) == 0)
|
||||||
@ -431,35 +435,20 @@ static void refreshInstance(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (paramtype == SQLVAR_TARGET_TYPE)
|
||||||
if (paramtype == BOOL_TYPE)
|
|
||||||
{
|
{
|
||||||
if (strncmp(param->name,
|
if (strncmp(param->name,
|
||||||
"read_ses_variables_from_slaves",
|
"use_sql_variables_in",
|
||||||
MAX_PARAM_LEN) == 0)
|
MAX_PARAM_LEN) == 0)
|
||||||
{
|
{
|
||||||
bool val;
|
target_t valtarget;
|
||||||
bool succp;
|
bool succp;
|
||||||
|
|
||||||
succp = config_get_valbool(&val, param, NULL, paramtype);
|
succp = config_get_valtarget(&valtarget, param, NULL, paramtype);
|
||||||
|
|
||||||
if (succp)
|
if (succp)
|
||||||
{
|
{
|
||||||
router->rwsplit_config.rw_read_sesvars_from_slaves = val;
|
router->rwsplit_config.rw_use_sql_variables_in = valtarget;
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (strncmp(param->name,
|
|
||||||
"write_ses_variables_to_all",
|
|
||||||
MAX_PARAM_LEN) == 0)
|
|
||||||
{
|
|
||||||
bool val;
|
|
||||||
bool succp;
|
|
||||||
|
|
||||||
succp = config_get_valbool(&val, param, NULL, paramtype);
|
|
||||||
|
|
||||||
if (succp)
|
|
||||||
{
|
|
||||||
router->rwsplit_config.rw_write_sesvars_to_all = val;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -693,16 +682,9 @@ createInstance(SERVICE *service, char **options)
|
|||||||
}
|
}
|
||||||
router->rwsplit_version = service->svc_config_version;
|
router->rwsplit_version = service->svc_config_version;
|
||||||
/** Set default values */
|
/** Set default values */
|
||||||
router->rwsplit_config.rw_read_sesvars_from_slaves = CONFIG_READ_SESVARS_FROM_SLAVES;
|
router->rwsplit_config.rw_use_sql_variables_in = CONFIG_SQL_VARIABLES_IN;
|
||||||
router->rwsplit_config.rw_write_sesvars_to_all = CONFIG_WRITE_SESVARS_TO_ALL;
|
param = config_get_param(service->svc_config_param, "use_sql_variable_in");
|
||||||
param = config_get_param(service->svc_config_param, "read_ses_variables_from_slaves");
|
|
||||||
|
|
||||||
if (param != NULL)
|
|
||||||
{
|
|
||||||
refreshInstance(router, param);
|
|
||||||
}
|
|
||||||
param = config_get_param(service->svc_config_param, "write_ses_variables_to_all");
|
|
||||||
|
|
||||||
if (param != NULL)
|
if (param != NULL)
|
||||||
{
|
{
|
||||||
refreshInstance(router, param);
|
refreshInstance(router, param);
|
||||||
@ -1185,8 +1167,7 @@ return_succp:
|
|||||||
static route_target_t get_route_target (
|
static route_target_t get_route_target (
|
||||||
skygw_query_type_t qtype,
|
skygw_query_type_t qtype,
|
||||||
bool trx_active,
|
bool trx_active,
|
||||||
bool read_ses_variables_from_slaves,
|
target_t use_sql_variables_in,
|
||||||
bool write_ses_variables_to_all,
|
|
||||||
HINT* hint)
|
HINT* hint)
|
||||||
{
|
{
|
||||||
route_target_t target;
|
route_target_t target;
|
||||||
@ -1197,7 +1178,7 @@ static route_target_t get_route_target (
|
|||||||
(QUERY_IS_TYPE(qtype, QUERY_TYPE_PREPARE_STMT) ||
|
(QUERY_IS_TYPE(qtype, QUERY_TYPE_PREPARE_STMT) ||
|
||||||
QUERY_IS_TYPE(qtype, QUERY_TYPE_PREPARE_NAMED_STMT) ||
|
QUERY_IS_TYPE(qtype, QUERY_TYPE_PREPARE_NAMED_STMT) ||
|
||||||
/** Configured to allow writing variables to all nodes */
|
/** Configured to allow writing variables to all nodes */
|
||||||
(write_ses_variables_to_all &&
|
(use_sql_variables_in == TYPE_ALL &&
|
||||||
(QUERY_IS_TYPE(qtype, QUERY_TYPE_SESSION_WRITE) ||
|
(QUERY_IS_TYPE(qtype, QUERY_TYPE_SESSION_WRITE) ||
|
||||||
QUERY_IS_TYPE(qtype, QUERY_TYPE_GSYSVAR_WRITE)))))
|
QUERY_IS_TYPE(qtype, QUERY_TYPE_GSYSVAR_WRITE)))))
|
||||||
{
|
{
|
||||||
@ -1217,7 +1198,7 @@ static route_target_t get_route_target (
|
|||||||
/** First set expected targets before evaluating hints */
|
/** First set expected targets before evaluating hints */
|
||||||
if (QUERY_IS_TYPE(qtype, QUERY_TYPE_READ) ||
|
if (QUERY_IS_TYPE(qtype, QUERY_TYPE_READ) ||
|
||||||
/** Configured to allow reading variables from slaves */
|
/** Configured to allow reading variables from slaves */
|
||||||
(read_ses_variables_from_slaves &&
|
(use_sql_variables_in == TYPE_ALL &&
|
||||||
(QUERY_IS_TYPE(qtype, QUERY_TYPE_USERVAR_READ) ||
|
(QUERY_IS_TYPE(qtype, QUERY_TYPE_USERVAR_READ) ||
|
||||||
QUERY_IS_TYPE(qtype, QUERY_TYPE_SYSVAR_READ) ||
|
QUERY_IS_TYPE(qtype, QUERY_TYPE_SYSVAR_READ) ||
|
||||||
QUERY_IS_TYPE(qtype, QUERY_TYPE_GSYSVAR_READ))))
|
QUERY_IS_TYPE(qtype, QUERY_TYPE_GSYSVAR_READ))))
|
||||||
@ -1226,13 +1207,12 @@ static route_target_t get_route_target (
|
|||||||
}
|
}
|
||||||
else if (QUERY_IS_TYPE(qtype, QUERY_TYPE_EXEC_STMT) ||
|
else if (QUERY_IS_TYPE(qtype, QUERY_TYPE_EXEC_STMT) ||
|
||||||
/** Configured not to allow reading variables from slaves */
|
/** Configured not to allow reading variables from slaves */
|
||||||
(!read_ses_variables_from_slaves &&
|
(use_sql_variables_in == TYPE_MASTER &&
|
||||||
(QUERY_IS_TYPE(qtype, QUERY_TYPE_USERVAR_READ) ||
|
(QUERY_IS_TYPE(qtype, QUERY_TYPE_USERVAR_READ) ||
|
||||||
QUERY_IS_TYPE(qtype, QUERY_TYPE_SYSVAR_READ))))
|
QUERY_IS_TYPE(qtype, QUERY_TYPE_SYSVAR_READ))))
|
||||||
{
|
{
|
||||||
target = TARGET_MASTER;
|
target = TARGET_MASTER;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** process routing hints */
|
/** process routing hints */
|
||||||
while (hint != NULL)
|
while (hint != NULL)
|
||||||
{
|
{
|
||||||
@ -1306,13 +1286,13 @@ static route_target_t get_route_target (
|
|||||||
QUERY_IS_TYPE(qtype, QUERY_TYPE_MASTER_READ) ||
|
QUERY_IS_TYPE(qtype, QUERY_TYPE_MASTER_READ) ||
|
||||||
QUERY_IS_TYPE(qtype, QUERY_TYPE_SESSION_WRITE) ||
|
QUERY_IS_TYPE(qtype, QUERY_TYPE_SESSION_WRITE) ||
|
||||||
(QUERY_IS_TYPE(qtype, QUERY_TYPE_USERVAR_READ) &&
|
(QUERY_IS_TYPE(qtype, QUERY_TYPE_USERVAR_READ) &&
|
||||||
!write_ses_variables_to_all) ||
|
use_sql_variables_in == TYPE_MASTER) ||
|
||||||
(QUERY_IS_TYPE(qtype, QUERY_TYPE_SYSVAR_READ) &&
|
(QUERY_IS_TYPE(qtype, QUERY_TYPE_SYSVAR_READ) &&
|
||||||
!write_ses_variables_to_all) ||
|
use_sql_variables_in == TYPE_MASTER) ||
|
||||||
(QUERY_IS_TYPE(qtype, QUERY_TYPE_GSYSVAR_READ) &&
|
(QUERY_IS_TYPE(qtype, QUERY_TYPE_GSYSVAR_READ) &&
|
||||||
!write_ses_variables_to_all) ||
|
use_sql_variables_in == TYPE_MASTER) ||
|
||||||
(QUERY_IS_TYPE(qtype, QUERY_TYPE_GSYSVAR_WRITE) &&
|
(QUERY_IS_TYPE(qtype, QUERY_TYPE_GSYSVAR_WRITE) &&
|
||||||
!write_ses_variables_to_all) ||
|
use_sql_variables_in == TYPE_MASTER) ||
|
||||||
QUERY_IS_TYPE(qtype, QUERY_TYPE_BEGIN_TRX) ||
|
QUERY_IS_TYPE(qtype, QUERY_TYPE_BEGIN_TRX) ||
|
||||||
QUERY_IS_TYPE(qtype, QUERY_TYPE_ENABLE_AUTOCOMMIT) ||
|
QUERY_IS_TYPE(qtype, QUERY_TYPE_ENABLE_AUTOCOMMIT) ||
|
||||||
QUERY_IS_TYPE(qtype, QUERY_TYPE_DISABLE_AUTOCOMMIT) ||
|
QUERY_IS_TYPE(qtype, QUERY_TYPE_DISABLE_AUTOCOMMIT) ||
|
||||||
@ -1775,8 +1755,7 @@ static int routeQuery(
|
|||||||
*/
|
*/
|
||||||
route_target = get_route_target(qtype,
|
route_target = get_route_target(qtype,
|
||||||
router_cli_ses->rses_transaction_active,
|
router_cli_ses->rses_transaction_active,
|
||||||
router_cli_ses->rses_config.rw_read_sesvars_from_slaves,
|
router_cli_ses->rses_config.rw_use_sql_variables_in,
|
||||||
router_cli_ses->rses_config.rw_write_sesvars_to_all,
|
|
||||||
querybuf->hint);
|
querybuf->hint);
|
||||||
|
|
||||||
if (TARGET_IS_ALL(route_target))
|
if (TARGET_IS_ALL(route_target))
|
||||||
|
@ -279,9 +279,9 @@ do
|
|||||||
printf "."
|
printf "."
|
||||||
fi
|
fi
|
||||||
b=`$RUNCMD < $TINPUT 2>&1`
|
b=`$RUNCMD < $TINPUT 2>&1`
|
||||||
if [[ "`echo "$b"|grep -i 'null|error'`" != "" ]]
|
if [[ "`echo "$b"|grep -i 'null\|error'`" != "" ]]
|
||||||
then
|
then
|
||||||
err=`echo "$b" | grep -i null|error`
|
err=`echo "$b" | grep -i null\|error`
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
Reference in New Issue
Block a user