Initial implementation of the support for multiple slaves in read/write split router session. Omits configuration changes.
This commit is contained in:
@ -31,15 +31,14 @@
|
|||||||
|
|
||||||
#include <dcb.h>
|
#include <dcb.h>
|
||||||
|
|
||||||
/**
|
|
||||||
* Internal structure used to define the set of backend servers we are routing
|
typedef enum backend_type_t {
|
||||||
* connections to. This provides the storage for routing module specific data
|
BE_UNDEFINED=-1,
|
||||||
* that is required for each of the backend servers.
|
BE_MASTER,
|
||||||
*/
|
BE_JOINED = BE_MASTER,
|
||||||
typedef struct backend {
|
BE_SLAVE,
|
||||||
SERVER* backend_server; /*< The server itself */
|
BE_COUNT
|
||||||
int backend_conn_count; /*< Number of connections to the server */
|
} backend_type_t;
|
||||||
} BACKEND;
|
|
||||||
|
|
||||||
typedef struct rses_property_st rses_property_t;
|
typedef struct rses_property_st rses_property_t;
|
||||||
typedef struct router_client_session ROUTER_CLIENT_SES;
|
typedef struct router_client_session ROUTER_CLIENT_SES;
|
||||||
@ -52,14 +51,6 @@ typedef enum rses_property_type_t {
|
|||||||
RSES_PROP_TYPE_COUNT=RSES_PROP_TYPE_LAST+1
|
RSES_PROP_TYPE_COUNT=RSES_PROP_TYPE_LAST+1
|
||||||
} rses_property_type_t;
|
} rses_property_type_t;
|
||||||
|
|
||||||
typedef enum backend_type_t {
|
|
||||||
BE_UNDEFINED=-1,
|
|
||||||
BE_MASTER,
|
|
||||||
BE_JOINED = BE_MASTER,
|
|
||||||
BE_SLAVE,
|
|
||||||
BE_COUNT
|
|
||||||
} backend_type_t;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Session variable command
|
* Session variable command
|
||||||
*/
|
*/
|
||||||
@ -98,13 +89,38 @@ struct rses_property_st {
|
|||||||
};
|
};
|
||||||
|
|
||||||
typedef struct sescmd_cursor_st {
|
typedef struct sescmd_cursor_st {
|
||||||
|
#if defined(SS_DEBUG)
|
||||||
|
skygw_chk_t scmd_cur_chk_top;
|
||||||
|
#endif
|
||||||
ROUTER_CLIENT_SES* scmd_cur_rses; /*< pointer to owning router session */
|
ROUTER_CLIENT_SES* scmd_cur_rses; /*< pointer to owning router session */
|
||||||
rses_property_t** scmd_cur_ptr_property; /*< address of pointer to owner property */
|
rses_property_t** scmd_cur_ptr_property; /*< address of pointer to owner property */
|
||||||
mysql_sescmd_t* scmd_cur_cmd; /*< pointer to current session command */
|
mysql_sescmd_t* scmd_cur_cmd; /*< pointer to current session command */
|
||||||
bool scmd_cur_active; /*< true if command is being executed */
|
bool scmd_cur_active; /*< true if command is being executed */
|
||||||
backend_type_t scmd_cur_be_type; /*< BE_MASTER or BE_SLAVE */
|
#if defined(SS_DEBUG)
|
||||||
|
skygw_chk_t scmd_cur_chk_tail;
|
||||||
|
#endif
|
||||||
} sescmd_cursor_t;
|
} sescmd_cursor_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
typedef struct backend {
|
||||||
|
#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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The client session structure used within this router.
|
* The client session structure used within this router.
|
||||||
*/
|
*/
|
||||||
@ -113,14 +129,13 @@ struct router_client_session {
|
|||||||
skygw_chk_t rses_chk_top;
|
skygw_chk_t rses_chk_top;
|
||||||
#endif
|
#endif
|
||||||
SPINLOCK rses_lock; /*< protects rses_deleted */
|
SPINLOCK rses_lock; /*< protects rses_deleted */
|
||||||
int rses_versno; /*< even = no active update, else odd */
|
int rses_versno; /*< even = no active update, else odd. not used 4/14 */
|
||||||
bool rses_closed; /*< true when closeSession is called */
|
bool rses_closed; /*< true when closeSession is called */
|
||||||
/** Properties listed by their type */
|
/** Properties listed by their type */
|
||||||
rses_property_t* rses_properties[RSES_PROP_TYPE_COUNT];
|
rses_property_t* rses_properties[RSES_PROP_TYPE_COUNT];
|
||||||
BACKEND* rses_backend[BE_COUNT];/*< Backends used by client session */
|
BACKEND* rses_master; /*< Pointer to master */
|
||||||
DCB* rses_dcb[BE_COUNT];
|
BACKEND** rses_backend; /*< All backends used by client session */
|
||||||
/*< cursor is pointer and status variable to current session command */
|
int rses_nbackends;
|
||||||
sescmd_cursor_t rses_cursor[BE_COUNT];
|
|
||||||
int rses_capabilities; /*< input type, for example */
|
int rses_capabilities; /*< input type, for example */
|
||||||
struct router_client_session* next;
|
struct router_client_session* next;
|
||||||
#if defined(SS_DEBUG)
|
#if defined(SS_DEBUG)
|
||||||
|
@ -682,7 +682,7 @@ int gw_read_client_event(DCB* dcb) {
|
|||||||
dcb,
|
dcb,
|
||||||
1,
|
1,
|
||||||
0,
|
0,
|
||||||
"Query routing failed. Connection to "
|
"Can't route query. Connection to "
|
||||||
"backend lost");
|
"backend lost");
|
||||||
protocol->state = MYSQL_IDLE;
|
protocol->state = MYSQL_IDLE;
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -119,7 +119,9 @@ typedef enum skygw_chk_t {
|
|||||||
CHK_NUM_SESSION,
|
CHK_NUM_SESSION,
|
||||||
CHK_NUM_ROUTER_SES,
|
CHK_NUM_ROUTER_SES,
|
||||||
CHK_NUM_MY_SESCMD,
|
CHK_NUM_MY_SESCMD,
|
||||||
CHK_NUM_ROUTER_PROPERTY
|
CHK_NUM_ROUTER_PROPERTY,
|
||||||
|
CHK_NUM_SESCMD_CUR,
|
||||||
|
CHK_NUM_BACKEND
|
||||||
} skygw_chk_t;
|
} skygw_chk_t;
|
||||||
|
|
||||||
# define STRBOOL(b) ((b) ? "true" : "false")
|
# define STRBOOL(b) ((b) ? "true" : "false")
|
||||||
@ -446,6 +448,17 @@ typedef enum skygw_chk_t {
|
|||||||
"Session command has invalid check fields"); \
|
"Session command has invalid check fields"); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define CHK_SESCMD_CUR(c) { \
|
||||||
|
ss_info_dassert((c)->scmd_cur_chk_top == CHK_NUM_SESCMD_CUR && \
|
||||||
|
(c)->scmd_cur_chk_tail == CHK_NUM_SESCMD_CUR, \
|
||||||
|
"Session command cursor has invalid check fields"); \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define CHK_BACKEND(b) { \
|
||||||
|
ss_info_dassert((b)->be_chk_top == CHK_NUM_BACKEND && \
|
||||||
|
(b)->be_chk_tail == CHK_NUM_BACKEND, \
|
||||||
|
"BACKEND has invalid check fields"); \
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(SS_DEBUG)
|
#if defined(SS_DEBUG)
|
||||||
bool conn_open[10240];
|
bool conn_open[10240];
|
||||||
|
Reference in New Issue
Block a user