Fix to bug #541, http://bugs.skysql.com/show_bug.cgi?id=541
Long ~0.5MB queries blocked MaxScale. mysql_client.c:gw_read_client_event: Fixed packet reading logic. Reading didn't work when packet exceeded read buffer size. mysql_common.c:gw_MySQL_get_next_packet: number of bytes to be copied to continuous buffer was calculated wrong, thus resulting in broken packet. readwritesplit.c:disabled creation of canonical query in debug build because it slows down the processing too much with long queries
This commit is contained in:
@ -552,15 +552,17 @@ int gw_read_client_event(
|
|||||||
*/
|
*/
|
||||||
if (dcb->dcb_readqueue)
|
if (dcb->dcb_readqueue)
|
||||||
{
|
{
|
||||||
uint8_t* data = (uint8_t *)GWBUF_DATA(read_buffer);
|
uint8_t* data;
|
||||||
|
|
||||||
read_buffer = gwbuf_append(dcb->dcb_readqueue, read_buffer);
|
dcb->dcb_readqueue = gwbuf_append(dcb->dcb_readqueue, read_buffer);
|
||||||
nbytes_read = gwbuf_length(read_buffer);
|
nbytes_read = gwbuf_length(dcb->dcb_readqueue);
|
||||||
|
data = (uint8_t *)GWBUF_DATA(dcb->dcb_readqueue);
|
||||||
|
|
||||||
if (nbytes_read < 3 || nbytes_read < MYSQL_GET_PACKET_LEN(data))
|
if (nbytes_read < 3 || nbytes_read < MYSQL_GET_PACKET_LEN(data))
|
||||||
{
|
{
|
||||||
rc = 0;
|
size_t nread = MYSQL_GET_PACKET_LEN(data);
|
||||||
goto return_rc;
|
rc = 0;
|
||||||
|
goto return_rc;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -578,7 +580,8 @@ int gw_read_client_event(
|
|||||||
|
|
||||||
if (nbytes_read < 3 || nbytes_read < MYSQL_GET_PACKET_LEN(data)+4)
|
if (nbytes_read < 3 || nbytes_read < MYSQL_GET_PACKET_LEN(data)+4)
|
||||||
{
|
{
|
||||||
dcb->dcb_readqueue = gwbuf_append(dcb->dcb_readqueue, read_buffer);
|
size_t nread = MYSQL_GET_PACKET_LEN(data);
|
||||||
|
dcb->dcb_readqueue = gwbuf_append(dcb->dcb_readqueue, read_buffer);
|
||||||
rc = 0;
|
rc = 0;
|
||||||
goto return_rc;
|
goto return_rc;
|
||||||
}
|
}
|
||||||
@ -789,7 +792,7 @@ int gw_read_client_event(
|
|||||||
if (read_buffer != NULL)
|
if (read_buffer != NULL)
|
||||||
{
|
{
|
||||||
/** add incomplete mysql packet to read queue */
|
/** add incomplete mysql packet to read queue */
|
||||||
gwbuf_append(dcb->dcb_readqueue, read_buffer);
|
dcb->dcb_readqueue = gwbuf_append(dcb->dcb_readqueue, read_buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1443,7 +1446,11 @@ static int route_by_statement(
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
ss_dassert(GWBUF_IS_TYPE_MYSQL((*p_readbuf)));
|
ss_dassert(GWBUF_IS_TYPE_MYSQL((*p_readbuf)));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collect incoming bytes to a buffer until complete packet has
|
||||||
|
* arrived and then return the buffer.
|
||||||
|
*/
|
||||||
packetbuf = gw_MySQL_get_next_packet(p_readbuf);
|
packetbuf = gw_MySQL_get_next_packet(p_readbuf);
|
||||||
|
|
||||||
if (packetbuf != NULL)
|
if (packetbuf != NULL)
|
||||||
|
@ -1530,9 +1530,7 @@ GWBUF* gw_MySQL_get_next_packet(
|
|||||||
{
|
{
|
||||||
packetbuf = NULL;
|
packetbuf = NULL;
|
||||||
goto return_packetbuf;
|
goto return_packetbuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
buflen = GWBUF_LENGTH((readbuf));
|
|
||||||
totalbuflen = gwbuf_length(readbuf);
|
totalbuflen = gwbuf_length(readbuf);
|
||||||
data = (uint8_t *)GWBUF_DATA((readbuf));
|
data = (uint8_t *)GWBUF_DATA((readbuf));
|
||||||
packetlen = MYSQL_GET_PACKET_LEN(data)+4;
|
packetlen = MYSQL_GET_PACKET_LEN(data)+4;
|
||||||
@ -1556,6 +1554,7 @@ GWBUF* gw_MySQL_get_next_packet(
|
|||||||
uint8_t* src = GWBUF_DATA((*p_readbuf));
|
uint8_t* src = GWBUF_DATA((*p_readbuf));
|
||||||
size_t bytestocopy;
|
size_t bytestocopy;
|
||||||
|
|
||||||
|
buflen = GWBUF_LENGTH((*p_readbuf));
|
||||||
bytestocopy = MIN(buflen,packetlen-nbytes_copied);
|
bytestocopy = MIN(buflen,packetlen-nbytes_copied);
|
||||||
|
|
||||||
memcpy(target+nbytes_copied, src, bytestocopy);
|
memcpy(target+nbytes_copied, src, bytestocopy);
|
||||||
@ -1569,7 +1568,6 @@ return_packetbuf:
|
|||||||
return packetbuf;
|
return packetbuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Move <npackets> from buffer pointed to by <*p_readbuf>.
|
* Move <npackets> from buffer pointed to by <*p_readbuf>.
|
||||||
*/
|
*/
|
||||||
|
@ -1949,7 +1949,7 @@ static int routeQuery(
|
|||||||
}
|
}
|
||||||
rses_end_locked_router_action(router_cli_ses);
|
rses_end_locked_router_action(router_cli_ses);
|
||||||
retblock:
|
retblock:
|
||||||
#if defined(SS_DEBUG)
|
#if defined(SS_DEBUG2)
|
||||||
{
|
{
|
||||||
char* canonical_query_str;
|
char* canonical_query_str;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user