diff --git a/include/maxscale/buffer.h b/include/maxscale/buffer.h index 4fc80ac9c..375d85b88 100644 --- a/include/maxscale/buffer.h +++ b/include/maxscale/buffer.h @@ -52,20 +52,14 @@ typedef struct buf_property typedef enum { GWBUF_TYPE_UNDEFINED = 0x00, - GWBUF_TYPE_PLAINSQL = 0x01, - GWBUF_TYPE_MYSQL = 0x02, - GWBUF_TYPE_SINGLE_STMT = 0x04, - GWBUF_TYPE_SESCMD_RESPONSE = 0x08, - GWBUF_TYPE_RESPONSE_END = 0x10, - GWBUF_TYPE_SESCMD = 0x20, - GWBUF_TYPE_HTTP = 0x40, - GWBUF_TYPE_IGNORABLE = 0x80 + GWBUF_TYPE_SESCMD_RESPONSE = 0x01, + GWBUF_TYPE_RESPONSE_END = 0x02, + GWBUF_TYPE_SESCMD = 0x04, + GWBUF_TYPE_HTTP = 0x08, + GWBUF_TYPE_IGNORABLE = 0x10 } gwbuf_type_t; #define GWBUF_IS_TYPE_UNDEFINED(b) (b->gwbuf_type == 0) -#define GWBUF_IS_TYPE_PLAINSQL(b) (b->gwbuf_type & GWBUF_TYPE_PLAINSQL) -#define GWBUF_IS_TYPE_MYSQL(b) (b->gwbuf_type & GWBUF_TYPE_MYSQL) -#define GWBUF_IS_TYPE_SINGLE_STMT(b) (b->gwbuf_type & GWBUF_TYPE_SINGLE_STMT) #define GWBUF_IS_TYPE_SESCMD_RESPONSE(b) (b->gwbuf_type & GWBUF_TYPE_SESCMD_RESPONSE) #define GWBUF_IS_TYPE_RESPONSE_END(b) (b->gwbuf_type & GWBUF_TYPE_RESPONSE_END) #define GWBUF_IS_TYPE_SESCMD(b) (b->gwbuf_type & GWBUF_TYPE_SESCMD) diff --git a/server/core/dcb.cc b/server/core/dcb.cc index a731922db..768a588c2 100644 --- a/server/core/dcb.cc +++ b/server/core/dcb.cc @@ -1273,67 +1273,13 @@ dcb_write_parameter_check(DCB *dcb, GWBUF *queue) static void dcb_log_write_failure(DCB *dcb, GWBUF *queue, int eno) { - if (MXS_LOG_PRIORITY_IS_ENABLED(LOG_DEBUG)) - { - if (eno == EPIPE) - { - MXS_DEBUG("%lu [dcb_write] Write to dcb " - "%p in state %s fd %d failed " - "due errno %d, %s", - pthread_self(), - dcb, - STRDCBSTATE(dcb->state), - dcb->fd, - eno, - mxs_strerror(eno)); - } - } - - if (MXS_LOG_PRIORITY_IS_ENABLED(LOG_ERR)) - { - if (eno != EPIPE && - eno != EAGAIN && - eno != EWOULDBLOCK) - { - MXS_ERROR("Write to dcb %p in " - "state %s fd %d failed due " - "errno %d, %s", - dcb, - STRDCBSTATE(dcb->state), - dcb->fd, - eno, - mxs_strerror(eno)); - - } - - } - - bool dolog = true; - - if (eno != 0 && - eno != EAGAIN && + if (eno != EPIPE && + eno != EAGAIN && eno != EWOULDBLOCK) { - /** - * Do not log if writing COM_QUIT to backend failed. - */ - if (GWBUF_IS_TYPE_MYSQL(queue)) - { - uint8_t* data = GWBUF_DATA(queue); + MXS_ERROR("Write to dcb %p in state %s fd %d failed: %d, %s", + dcb, STRDCBSTATE(dcb->state), dcb->fd, eno, mxs_strerror(eno)); - if (data[4] == 0x01) - { - dolog = false; - } - } - if (dolog) - { - MXS_DEBUG("%lu [dcb_write] Writing to %s socket failed due %d, %s.", - pthread_self(), - DCB_ROLE_CLIENT_HANDLER == dcb->dcb_role ? "client" : "backend server", - eno, - mxs_strerror(eno)); - } } } diff --git a/server/core/modutil.cc b/server/core/modutil.cc index 607855a80..4472fe68f 100644 --- a/server/core/modutil.cc +++ b/server/core/modutil.cc @@ -1004,7 +1004,6 @@ GWBUF* modutil_create_query(const char* query) *ptr++ = 0x0; *ptr++ = 0x03; memcpy(ptr, query, strlen(query)); - gwbuf_set_type(rval, GWBUF_TYPE_MYSQL); } return rval; diff --git a/server/modules/protocol/MySQL/MySQLBackend/mysql_backend.c b/server/modules/protocol/MySQL/MySQLBackend/mysql_backend.c index 328d5c3b0..0ccf20748 100644 --- a/server/modules/protocol/MySQL/MySQLBackend/mysql_backend.c +++ b/server/modules/protocol/MySQL/MySQLBackend/mysql_backend.c @@ -781,7 +781,6 @@ gw_read_and_write(DCB *dcb) if (session_ok_to_route(dcb)) { - gwbuf_set_type(stmt, GWBUF_TYPE_MYSQL); session->service->router->clientReply(session->service->router_instance, session->router_session, stmt, dcb); @@ -964,8 +963,7 @@ static int gw_MySQLWrite_backend(DCB *dcb, GWBUF *queue) * Server commands are stored to MySQLProtocol structure * if buffer always includes a single statement. */ - if (GWBUF_IS_TYPE_SINGLE_STMT(queue) && - GWBUF_IS_TYPE_SESCMD(queue)) + if (GWBUF_IS_TYPE_SESCMD(queue)) { /** Record the command to backend's protocol */ protocol_add_srv_command(backend_protocol, cmd); @@ -1004,8 +1002,7 @@ static int gw_MySQLWrite_backend(DCB *dcb, GWBUF *queue) * In case of session commands, store command to DCB's * protocol struct. */ - if (GWBUF_IS_TYPE_SINGLE_STMT(queue) && - GWBUF_IS_TYPE_SESCMD(queue)) + if (GWBUF_IS_TYPE_SESCMD(queue)) { uint8_t* ptr = GWBUF_DATA(queue); mysql_server_cmd_t cmd = MYSQL_GET_COMMAND(ptr); @@ -1130,7 +1127,6 @@ static int gw_backend_close(DCB *dcb) /** Send COM_QUIT to the backend being closed */ GWBUF* quitbuf = mysql_create_com_quit(NULL, 0); - gwbuf_set_type(quitbuf, GWBUF_TYPE_MYSQL); mysql_send_com_quit(dcb, 0, quitbuf); /** Free protocol data */ @@ -1623,7 +1619,6 @@ gw_create_change_user_packet(MYSQL_session* mses, char* user; uint8_t* pwd; GWBUF* buffer; - int compress = 0; uint8_t* payload = NULL; uint8_t* payload_start = NULL; long bytes; @@ -1649,13 +1644,6 @@ gw_create_change_user_packet(MYSQL_session* mses, /* get charset the client sent and use it for connection auth */ charset = protocol->charset; - if (compress) - { -#ifdef DEBUG_MYSQL_CONN - fprintf(stderr, ">>>> Backend Connection with compression\n"); -#endif - } - /** * Protocol MySQL COM_CHANGE_USER for CLIENT_PROTOCOL_41 * 1 byte COMMAND @@ -1695,7 +1683,7 @@ gw_create_change_user_packet(MYSQL_session* mses, * Set correct type to GWBUF so that it will be handled like session * commands */ - buffer->gwbuf_type = GWBUF_TYPE_MYSQL | GWBUF_TYPE_SINGLE_STMT | GWBUF_TYPE_SESCMD; + buffer->gwbuf_type = GWBUF_TYPE_SESCMD; payload = GWBUF_DATA(buffer); memset(payload, '\0', bytes); payload_start = payload; diff --git a/server/modules/protocol/MySQL/MySQLClient/mysql_client.c b/server/modules/protocol/MySQL/MySQLClient/mysql_client.c index fcbda2e62..4cab7131d 100644 --- a/server/modules/protocol/MySQL/MySQLClient/mysql_client.c +++ b/server/modules/protocol/MySQL/MySQLClient/mysql_client.c @@ -943,7 +943,6 @@ gw_read_normal_data(DCB *dcb, GWBUF *read_buffer, int nbytes_read) return 0; } - gwbuf_set_type(read_buffer, GWBUF_TYPE_MYSQL); } /** @@ -1388,20 +1387,8 @@ static int route_by_statement(MXS_SESSION* session, uint64_t capabilities, GWBUF { int rc; GWBUF* packetbuf; -#if defined(SS_DEBUG) - GWBUF* tmpbuf; - - tmpbuf = *p_readbuf; - while (tmpbuf != NULL) - { - ss_dassert(GWBUF_IS_TYPE_MYSQL(tmpbuf)); - tmpbuf = tmpbuf->next; - } -#endif do { - ss_dassert(GWBUF_IS_TYPE_MYSQL((*p_readbuf))); - /** * Collect incoming bytes to a buffer until complete packet has * arrived and then return the buffer. @@ -1412,7 +1399,6 @@ static int route_by_statement(MXS_SESSION* session, uint64_t capabilities, GWBUF if (packetbuf != NULL) { CHK_GWBUF(packetbuf); - ss_dassert(GWBUF_IS_TYPE_MYSQL(packetbuf)); /** * This means that buffer includes exactly one MySQL * statement. @@ -1425,8 +1411,6 @@ static int route_by_statement(MXS_SESSION* session, uint64_t capabilities, GWBUF * Set it here instead of gw_read_client_event to make * sure it is set to each (MySQL) packet. */ - gwbuf_set_type(packetbuf, GWBUF_TYPE_SINGLE_STMT); - if (rcap_type_required(capabilities, RCAP_TYPE_CONTIGUOUS_INPUT)) { if (!GWBUF_IS_CONTIGUOUS(packetbuf)) diff --git a/server/modules/routing/readwritesplit/readwritesplit.c b/server/modules/routing/readwritesplit/readwritesplit.c index 7f627e5ad..6c2f3249b 100644 --- a/server/modules/routing/readwritesplit/readwritesplit.c +++ b/server/modules/routing/readwritesplit/readwritesplit.c @@ -564,13 +564,9 @@ static int routeQuery(MXS_ROUTER *instance, MXS_ROUTER_SESSION *router_session, { closed_session_reply(querybuf); } - else + else if (route_single_stmt(inst, rses, querybuf)) { - live_session_reply(&querybuf, rses); - if (route_single_stmt(inst, rses, querybuf)) - { - rval = 1; - } + rval = 1; } if (querybuf != NULL) diff --git a/server/modules/routing/readwritesplit/rwsplit_internal.h b/server/modules/routing/readwritesplit/rwsplit_internal.h index 78f415218..d93472d26 100644 --- a/server/modules/routing/readwritesplit/rwsplit_internal.h +++ b/server/modules/routing/readwritesplit/rwsplit_internal.h @@ -47,7 +47,6 @@ do{ \ bool route_single_stmt(ROUTER_INSTANCE *inst, ROUTER_CLIENT_SES *rses, GWBUF *querybuf); void closed_session_reply(GWBUF *querybuf); -void live_session_reply(GWBUF **querybuf, ROUTER_CLIENT_SES *rses); void print_error_packet(ROUTER_CLIENT_SES *rses, GWBUF *buf, DCB *dcb); void check_session_command_reply(GWBUF *writebuf, sescmd_cursor_t *scur, backend_ref_t *bref); bool execute_sescmd_in_backend(backend_ref_t *backend_ref); diff --git a/server/modules/routing/readwritesplit/rwsplit_mysql.c b/server/modules/routing/readwritesplit/rwsplit_mysql.c index ab767e250..6952818b1 100644 --- a/server/modules/routing/readwritesplit/rwsplit_mysql.c +++ b/server/modules/routing/readwritesplit/rwsplit_mysql.c @@ -312,37 +312,6 @@ void closed_session_reply(GWBUF *querybuf) } } -/* - * Probably MySQL specific because of modutil function - */ -/** - * @brief First step to handle request in a live session - * - * Used when a request is about to be routed. Note that the query buffer is - * passed by name and is likely to be modified by this function. - * - * @param querybuf Query buffer containing packet - * @param rses Router session - */ -void live_session_reply(GWBUF **querybuf, ROUTER_CLIENT_SES *rses) -{ - GWBUF *tmpbuf = *querybuf; - if (GWBUF_IS_TYPE_UNDEFINED(tmpbuf)) - { - /* Note that many modutil functions are MySQL specific */ - *querybuf = modutil_get_complete_packets(&tmpbuf); - if (tmpbuf) - { - rses->client_dcb->dcb_readqueue = gwbuf_append(rses->client_dcb->dcb_readqueue, tmpbuf); - } - *querybuf = gwbuf_make_contiguous(*querybuf); - - /** Mark buffer to as MySQL type */ - gwbuf_set_type(*querybuf, GWBUF_TYPE_MYSQL); - gwbuf_set_type(*querybuf, GWBUF_TYPE_SINGLE_STMT); - } -} - /* * Uses MySQL specific mechanisms */ diff --git a/server/modules/routing/readwritesplit/rwsplit_route_stmt.c b/server/modules/routing/readwritesplit/rwsplit_route_stmt.c index 02b9b518b..3ad74b1ff 100644 --- a/server/modules/routing/readwritesplit/rwsplit_route_stmt.c +++ b/server/modules/routing/readwritesplit/rwsplit_route_stmt.c @@ -96,7 +96,6 @@ bool route_single_stmt(ROUTER_INSTANCE *inst, ROUTER_CLIENT_SES *rses, bool non_empty_packet; ss_dassert(querybuf->next == NULL); // The buffer must be contiguous. - ss_dassert(!GWBUF_IS_TYPE_UNDEFINED(querybuf)); /* packet_type is a problem as it is MySQL specific */ packet_type = determine_packet_type(querybuf, &non_empty_packet); diff --git a/server/modules/routing/schemarouter/schemaroutersession.cc b/server/modules/routing/schemarouter/schemaroutersession.cc index b977bc7a0..72cf14f14 100644 --- a/server/modules/routing/schemarouter/schemaroutersession.cc +++ b/server/modules/routing/schemarouter/schemaroutersession.cc @@ -266,8 +266,6 @@ static bool is_empty_packet(GWBUF* pPacket) int32_t SchemaRouterSession::routeQuery(GWBUF* pPacket) { - ss_dassert(!GWBUF_IS_TYPE_UNDEFINED(pPacket)); - if (m_closed) { return 0; @@ -959,7 +957,6 @@ bool SchemaRouterSession::handle_default_db() { uint8_t *data = GWBUF_DATA(buffer); gw_mysql_set_byte3(data, qlen + 1); - gwbuf_set_type(buffer, GWBUF_TYPE_MYSQL); data[3] = 0x0; data[4] = 0x2; memcpy(data + 5, m_connect_db.c_str(), qlen); @@ -1129,7 +1126,6 @@ void create_error_reply(char* fail_str, DCB* dcb) return; } /** Set flags that help router to identify session commands reply */ - gwbuf_set_type(errbuf, GWBUF_TYPE_MYSQL); gwbuf_set_type(errbuf, GWBUF_TYPE_SESCMD_RESPONSE); gwbuf_set_type(errbuf, GWBUF_TYPE_RESPONSE_END);