Make session state change tracking conditional

By making it conditional, we prevent the problems that arise when the
replication protocol is used in combination with the session state change
tracking. In addition to this, it prevents unnecessary work for routers
and filters that don't need it.
This commit is contained in:
Markus Mäkelä
2018-03-15 11:36:32 +02:00
parent f525822472
commit 20c5ca1619
4 changed files with 26 additions and 13 deletions

View File

@ -39,20 +39,22 @@ MXS_BEGIN_DECLS
typedef enum routing_capability typedef enum routing_capability
{ {
/**< Statements are delivered one per buffer. */ /**< Statements are delivered one per buffer. */
RCAP_TYPE_STMT_INPUT = 0x0001, /* 0b0000000000000001 */ RCAP_TYPE_STMT_INPUT = 0x0001, /* 0b0000000000000001 */
/**< Each delivered buffer is contiguous; implies RCAP_TYPE_STMT_INPUT. */ /**< Each delivered buffer is contiguous; implies RCAP_TYPE_STMT_INPUT. */
RCAP_TYPE_CONTIGUOUS_INPUT = 0x0003, /* 0b0000000000000011 */ RCAP_TYPE_CONTIGUOUS_INPUT = 0x0003, /* 0b0000000000000011 */
/**< The transaction state and autocommit mode of the session are tracked; /**< The transaction state and autocommit mode of the session are tracked;
implies RCAP_TYPE_CONTIGUOUS_INPUT and RCAP_TYPE_STMT_INPUT. */ implies RCAP_TYPE_CONTIGUOUS_INPUT and RCAP_TYPE_STMT_INPUT. */
RCAP_TYPE_TRANSACTION_TRACKING = 0x0007, /* 0b0000000000000111 */ RCAP_TYPE_TRANSACTION_TRACKING = 0x0007, /* 0b0000000000000111 */
/**< Responses are delivered one per buffer. */ /**< Responses are delivered one per buffer. */
RCAP_TYPE_STMT_OUTPUT = 0x0010, /* 0b0000000000010000 */ RCAP_TYPE_STMT_OUTPUT = 0x0010, /* 0b0000000000010000 */
/**< Each delivered buffer is contiguous; implies RCAP_TYPE_STMT_OUTPUT. */ /**< Each delivered buffer is contiguous; implies RCAP_TYPE_STMT_OUTPUT. */
RCAP_TYPE_CONTIGUOUS_OUTPUT = 0x0030, /* 0b0000000000110000 */ RCAP_TYPE_CONTIGUOUS_OUTPUT = 0x0030, /* 0b0000000000110000 */
/** Result sets are delivered in one buffer; implies RCAP_TYPE_STMT_OUTPUT. */ /** Result sets are delivered in one buffer; implies RCAP_TYPE_STMT_OUTPUT. */
RCAP_TYPE_RESULTSET_OUTPUT = 0x0050, /* 0b0000000001110000 */ RCAP_TYPE_RESULTSET_OUTPUT = 0x0050, /* 0b0000000001110000 */
/** Results are delivered as a set of complete packets */ /** Results are delivered as a set of complete packets */
RCAP_TYPE_PACKET_OUTPUT = 0x0080, /* 0b0000000010000000 */ RCAP_TYPE_PACKET_OUTPUT = 0x0080, /* 0b0000000010000000 */
/** Track session state changes, implies packet output */
RCAP_TYPE_SESSION_STATE_TRACKING = 0x0180, /* 0b0000000011000000 */
} mxs_routing_capability_t; } mxs_routing_capability_t;

View File

@ -766,8 +766,11 @@ gw_read_and_write(DCB *dcb)
return 0; return 0;
} }
/** Get sesion track info from ok packet and save it to gwbuf properties */ if (rcap_type_required(capabilities, RCAP_TYPE_SESSION_STATE_TRACKING))
mxs_mysql_get_session_track_info(tmp, proto); {
/** Get session track info from ok packet and save it to gwbuf properties */
mxs_mysql_get_session_track_info(tmp, proto);
}
read_buffer = tmp; read_buffer = tmp;

View File

@ -1229,8 +1229,14 @@ create_capabilities(MySQLProtocol *conn, bool with_ssl, bool db_specified, bool
/* Maybe it should depend on whether CA certificate is provided */ /* Maybe it should depend on whether CA certificate is provided */
/* final_capabilities |= (uint32_t)GW_MYSQL_CAPABILITIES_SSL_VERIFY_SERVER_CERT; */ /* final_capabilities |= (uint32_t)GW_MYSQL_CAPABILITIES_SSL_VERIFY_SERVER_CERT; */
} }
/** add session track */
final_capabilities |= (uint32_t)GW_MYSQL_CAPABILITIES_SESSION_TRACK; uint64_t capabilities = service_get_capabilities(conn->owner_dcb->session->service);
if (rcap_type_required(capabilities, RCAP_TYPE_SESSION_STATE_TRACKING))
{
/** add session track */
final_capabilities |= (uint32_t)GW_MYSQL_CAPABILITIES_SESSION_TRACK;
}
/** support multi statments */ /** support multi statments */
final_capabilities |= (uint32_t)GW_MYSQL_CAPABILITIES_MULTI_STATEMENTS; final_capabilities |= (uint32_t)GW_MYSQL_CAPABILITIES_MULTI_STATEMENTS;

View File

@ -1323,7 +1323,8 @@ static void clientReply(MXS_ROUTER *instance,
*/ */
static uint64_t getCapabilities(MXS_ROUTER* instance) static uint64_t getCapabilities(MXS_ROUTER* instance)
{ {
return RCAP_TYPE_STMT_INPUT | RCAP_TYPE_TRANSACTION_TRACKING | RCAP_TYPE_PACKET_OUTPUT; return RCAP_TYPE_STMT_INPUT | RCAP_TYPE_TRANSACTION_TRACKING |
RCAP_TYPE_PACKET_OUTPUT | RCAP_TYPE_SESSION_STATE_TRACKING;
} }
/** /**
@ -1469,7 +1470,8 @@ MXS_MODULE *MXS_CREATE_MODULE()
MXS_MODULE_API_ROUTER, MXS_MODULE_GA, MXS_ROUTER_VERSION, MXS_MODULE_API_ROUTER, MXS_MODULE_GA, MXS_ROUTER_VERSION,
"A Read/Write splitting router for enhancement read scalability", "A Read/Write splitting router for enhancement read scalability",
"V1.1.0", "V1.1.0",
RCAP_TYPE_STMT_INPUT | RCAP_TYPE_TRANSACTION_TRACKING | RCAP_TYPE_PACKET_OUTPUT, RCAP_TYPE_STMT_INPUT | RCAP_TYPE_TRANSACTION_TRACKING |
RCAP_TYPE_PACKET_OUTPUT | RCAP_TYPE_SESSION_STATE_TRACKING,
&MyObject, &MyObject,
NULL, /* Process init. */ NULL, /* Process init. */
NULL, /* Process finish. */ NULL, /* Process finish. */