Fixed two bugs of which one was older.
1. in query_classifier.cc autocommit_enabled, and transaction_active variables maintained their values across different sessions. Now those values are stored in each router_client_ses object. 2. As a part of implementation of MAX-95 session variables were added to BACKEND struct which is shared with all sessions using the SERVICE which the particular BACKEND serves. Now each router_client_ses object has a backend reference struct which includes pointer to BACKEND, DCB and to session command cursor. Added test - set_autocommit_disabled.sql, test_after_autocommit_disabled.sql - to check that session variable is discarded when session where it belongs terminates.
This commit is contained in:
parent
28bc3509cc
commit
c927057b5c
@ -764,7 +764,6 @@ static int is_autocommit_stmt(
|
||||
{
|
||||
String str(target, sizeof(target), system_charset_info);
|
||||
String* res = item->val_str(&str);
|
||||
int rc;
|
||||
|
||||
if ((rc = find_type(&bool_typelib, res->ptr(), res->length(), false)))
|
||||
{
|
||||
|
@ -136,7 +136,7 @@ static void usage(void);
|
||||
static char* get_expanded_pathname(
|
||||
char** abs_path,
|
||||
char* input_path,
|
||||
char* fname);
|
||||
const char* fname);
|
||||
static void print_log_n_stderr(
|
||||
bool do_log,
|
||||
bool do_stderr,
|
||||
@ -725,7 +725,7 @@ static bool file_is_writable(
|
||||
static char* get_expanded_pathname(
|
||||
char** output_path,
|
||||
char* relative_path,
|
||||
char* fname)
|
||||
const char* fname)
|
||||
{
|
||||
char* cnf_file_buf = NULL;
|
||||
char* expanded_path;
|
||||
@ -1228,7 +1228,7 @@ int main(int argc, char **argv)
|
||||
datadir)));
|
||||
LOGIF(LM, (skygw_log_write_flush(
|
||||
LOGFILE_MESSAGE,
|
||||
"Configuration file : %s",
|
||||
"Configuration file : %s",
|
||||
cnf_file_path)));
|
||||
|
||||
/*< Update the server options */
|
||||
|
@ -78,17 +78,18 @@ typedef struct {
|
||||
int n_threads; /**< Number of polling threads */
|
||||
} GATEWAY_CONF;
|
||||
|
||||
extern int config_load(char *);
|
||||
extern int config_reload();
|
||||
extern int config_threadcount();
|
||||
CONFIG_PARAMETER* config_get_param(CONFIG_PARAMETER* params, const char* name);
|
||||
extern int config_load(char *);
|
||||
extern int config_reload();
|
||||
extern int config_threadcount();
|
||||
CONFIG_PARAMETER* config_get_param(CONFIG_PARAMETER* params, const char* name);
|
||||
config_param_type_t config_get_paramtype(CONFIG_PARAMETER* param);
|
||||
CONFIG_PARAMETER* config_clone_param(CONFIG_PARAMETER* param);
|
||||
|
||||
bool config_set_qualified_param(
|
||||
CONFIG_PARAMETER* param,
|
||||
void* val,
|
||||
config_param_type_t type);
|
||||
|
||||
CONFIG_PARAMETER* config_clone_param(CONFIG_PARAMETER* param);
|
||||
|
||||
int config_get_valint(
|
||||
CONFIG_PARAMETER* param,
|
||||
|
@ -31,7 +31,6 @@
|
||||
|
||||
#include <dcb.h>
|
||||
|
||||
|
||||
typedef enum backend_type_t {
|
||||
BE_UNDEFINED=-1,
|
||||
BE_MASTER,
|
||||
@ -105,27 +104,45 @@ typedef struct sescmd_cursor_st {
|
||||
* Internal structure used to define the set of backend servers we are routing
|
||||
* connections to. This provides the storage for routing module specific data
|
||||
* that is required for each of the backend servers.
|
||||
*
|
||||
* Owned by router_instance, referenced by each routing session.
|
||||
*/
|
||||
typedef struct backend {
|
||||
typedef struct backend_st {
|
||||
#if defined(SS_DEBUG)
|
||||
skygw_chk_t be_chk_top;
|
||||
#endif
|
||||
SERVER* backend_server; /*< The server itself */
|
||||
int backend_conn_count; /*< Number of connections to the server */
|
||||
bool be_valid; /*< valid when belongs to the router's configuration */
|
||||
DCB* be_dcb;
|
||||
/*< cursor is pointer and status variable to current session command */
|
||||
sescmd_cursor_t be_sescmd_cursor;
|
||||
#if defined(SS_DEBUG)
|
||||
skygw_chk_t be_chk_tail;
|
||||
#endif
|
||||
} BACKEND;
|
||||
|
||||
|
||||
/**
|
||||
* Reference to BACKEND.
|
||||
*
|
||||
* Owned by router client session.
|
||||
*/
|
||||
typedef struct backend_ref_st {
|
||||
#if defined(SS_DEBUG)
|
||||
skygw_chk_t bref_chk_top;
|
||||
#endif
|
||||
BACKEND* bref_backend;
|
||||
DCB* bref_dcb;
|
||||
sescmd_cursor_t bref_sescmd_cur;
|
||||
#if defined(SS_DEBUG)
|
||||
skygw_chk_t bref_chk_tail;
|
||||
#endif
|
||||
} backend_ref_t;
|
||||
|
||||
|
||||
typedef struct rwsplit_config_st {
|
||||
int rw_max_slave_conn_percent;
|
||||
int rw_max_slave_conn_count;
|
||||
} rwsplit_config_t;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* The client session structure used within this router.
|
||||
@ -139,11 +156,13 @@ struct router_client_session {
|
||||
bool rses_closed; /*< true when closeSession is called */
|
||||
/** Properties listed by their type */
|
||||
rses_property_t* rses_properties[RSES_PROP_TYPE_COUNT];
|
||||
BACKEND* rses_master; /*< Pointer to master */
|
||||
BACKEND** rses_backend; /*< All backends used by client session */
|
||||
rwsplit_config_t rses_config; /*< copied config info from router instance */
|
||||
backend_ref_t* rses_master_ref;
|
||||
backend_ref_t* rses_backend_ref; /*< Pointer to backend reference array */
|
||||
rwsplit_config_t rses_config; /*< copied config info from router instance */
|
||||
int rses_nbackends;
|
||||
int rses_capabilities; /*< input type, for example */
|
||||
bool rses_autocommit_enabled;
|
||||
bool rses_transaction_active;
|
||||
struct router_client_session* next;
|
||||
#if defined(SS_DEBUG)
|
||||
skygw_chk_t rses_chk_tail;
|
||||
@ -178,4 +197,8 @@ typedef struct router_instance {
|
||||
struct router_instance* next; /*< Next router on the list */
|
||||
} ROUTER_INSTANCE;
|
||||
|
||||
#define BACKEND_TYPE(b) (SERVER_IS_MASTER((b)->backend_server) ? BE_MASTER : \
|
||||
(SERVER_IS_SLAVE((b)->backend_server) ? BE_SLAVE : \
|
||||
(SERVER_IS_JOINED((b)->backend_server) ? BE_JOINED : BE_UNDEFINED)));
|
||||
|
||||
#endif /*< _RWSPLITROUTER_H */
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -169,6 +169,8 @@ else
|
||||
echo "$TINPUT PASSED">>$TLOG ;
|
||||
fi
|
||||
|
||||
# Disable autocommit in the first session and then test in new session that
|
||||
# it is again enabled.
|
||||
TINPUT=test_autocommit_disabled2.sql
|
||||
TRETVAL=1
|
||||
a=`$RUNCMD < ./$TINPUT`
|
||||
@ -178,3 +180,14 @@ else
|
||||
echo "$TINPUT PASSED">>$TLOG ;
|
||||
fi
|
||||
|
||||
TINPUT=set_autocommit_disabled.sql
|
||||
`$RUNCMD < ./$TINPUT`
|
||||
TINPUT=test_after_autocommit_disabled.sql
|
||||
TRETVAL=$TMASTER_ID
|
||||
a=`$RUNCMD < ./$TINPUT`
|
||||
if [ "$a" == "$TRETVAL" ]; then
|
||||
echo "$TINPUT FAILED, return value $a when it was not accetable">>$TLOG;
|
||||
else
|
||||
echo "$TINPUT PASSED">>$TLOG ;
|
||||
fi
|
||||
|
||||
|
@ -0,0 +1,7 @@
|
||||
use test;
|
||||
drop table if exists t1;
|
||||
create table t1 (id integer);
|
||||
set autocommit=0; -- open transaction
|
||||
begin;
|
||||
insert into t1 values(1); -- write to master
|
||||
commit;
|
@ -0,0 +1,2 @@
|
||||
use test;
|
||||
select @@server_id;
|
@ -0,0 +1,9 @@
|
||||
use test;
|
||||
drop table if exists t1;
|
||||
create table t1 (id integer);
|
||||
set autocommit=0; -- open transaction
|
||||
begin;
|
||||
insert into t1 values(1); -- write to master
|
||||
commit;
|
||||
select count(*) from t1; -- read from master since autocommit is disabled
|
||||
drop table t1;
|
@ -121,7 +121,8 @@ typedef enum skygw_chk_t {
|
||||
CHK_NUM_MY_SESCMD,
|
||||
CHK_NUM_ROUTER_PROPERTY,
|
||||
CHK_NUM_SESCMD_CUR,
|
||||
CHK_NUM_BACKEND
|
||||
CHK_NUM_BACKEND,
|
||||
CHK_NUM_BACKEND_REF
|
||||
} skygw_chk_t;
|
||||
|
||||
# define STRBOOL(b) ((b) ? "true" : "false")
|
||||
@ -459,7 +460,14 @@ typedef enum skygw_chk_t {
|
||||
(b)->be_chk_tail == CHK_NUM_BACKEND, \
|
||||
"BACKEND has invalid check fields"); \
|
||||
}
|
||||
|
||||
|
||||
#define CHK_BACKEND_REF(r) { \
|
||||
ss_info_dassert((r)->bref_chk_top == CHK_NUM_BACKEND_REF && \
|
||||
(r)->bref_chk_tail == CHK_NUM_BACKEND_REF, \
|
||||
"Backend reference has invalid check fields"); \
|
||||
}
|
||||
|
||||
|
||||
#if defined(SS_DEBUG)
|
||||
bool conn_open[10240];
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user