Send COM_QUIT to backends if persistent connections are disabled
The COM_QUIT packets should be sent to the backends if persistent connections aren't used. This allows for a controlled shutdown of the connections on both ends even if the client closes the connection before all backends have authenticated.
This commit is contained in:
@ -1229,9 +1229,19 @@ static int gw_MySQLWrite_backend(DCB *dcb, GWBUF *queue)
|
|||||||
/** Record the command to backend's protocol */
|
/** Record the command to backend's protocol */
|
||||||
protocol_add_srv_command(backend_protocol, cmd);
|
protocol_add_srv_command(backend_protocol, cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cmd == MYSQL_COM_QUIT && dcb->server->persistpoolmax)
|
||||||
|
{
|
||||||
|
/** We need to keep the pooled connections alive so we just ignore the COM_QUIT packet */
|
||||||
|
gwbuf_free(queue);
|
||||||
|
rc = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
/** Write to backend */
|
/** Write to backend */
|
||||||
rc = dcb_write(dcb, queue);
|
rc = dcb_write(dcb, queue);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -1587,7 +1597,18 @@ static int backend_write_delayqueue(DCB *dcb, GWBUF *buffer)
|
|||||||
buffer = gw_create_change_user_packet(&mses, dcb->protocol);
|
buffer = gw_create_change_user_packet(&mses, dcb->protocol);
|
||||||
}
|
}
|
||||||
|
|
||||||
int rc = dcb_write(dcb, buffer);
|
int rc = 1;
|
||||||
|
|
||||||
|
if (MYSQL_IS_COM_QUIT(((uint8_t*)GWBUF_DATA(buffer))) && dcb->server->persistpoolmax)
|
||||||
|
{
|
||||||
|
/** We need to keep the pooled connections alive so we just ignore the COM_QUIT packet */
|
||||||
|
gwbuf_free(buffer);
|
||||||
|
rc = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rc = dcb_write(dcb, buffer);
|
||||||
|
}
|
||||||
|
|
||||||
if (rc == 0)
|
if (rc == 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -862,29 +862,9 @@ gw_read_finish_processing(DCB *dcb, GWBUF *read_buffer, uint8_t capabilities)
|
|||||||
SESSION *session = dcb->session;
|
SESSION *session = dcb->session;
|
||||||
uint8_t *payload = GWBUF_DATA(read_buffer);
|
uint8_t *payload = GWBUF_DATA(read_buffer);
|
||||||
MySQLProtocol *proto = (MySQLProtocol*)dcb->protocol;
|
MySQLProtocol *proto = (MySQLProtocol*)dcb->protocol;
|
||||||
CHK_PROTOCOL(proto)
|
CHK_PROTOCOL(proto);
|
||||||
int return_code = 0;
|
int return_code = 0;
|
||||||
|
|
||||||
/* Now, we are assuming in the first buffer there is
|
|
||||||
* the information for mysql command */
|
|
||||||
/* Route COM_QUIT to backend */
|
|
||||||
if (proto->current_command == MYSQL_COM_QUIT)
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Sends COM_QUIT packets since buffer is already
|
|
||||||
* created. A BREF_CLOSED flag is set so dcb_close won't
|
|
||||||
* send redundant COM_QUIT.
|
|
||||||
*/
|
|
||||||
/* Temporarily suppressed: SESSION_ROUTE_QUERY(session, read_buffer); */
|
|
||||||
/* Replaced with freeing the read buffer. */
|
|
||||||
gwbuf_free(read_buffer);
|
|
||||||
/**
|
|
||||||
* Close router session which causes closing of backends.
|
|
||||||
*/
|
|
||||||
dcb_close(dcb);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/** Reset error handler when routing of the new query begins */
|
/** Reset error handler when routing of the new query begins */
|
||||||
dcb->dcb_errhandle_called = false;
|
dcb->dcb_errhandle_called = false;
|
||||||
|
|
||||||
@ -947,7 +927,13 @@ gw_read_finish_processing(DCB *dcb, GWBUF *read_buffer, uint8_t capabilities)
|
|||||||
"Session will be closed.");
|
"Session will be closed.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (proto->current_command == MYSQL_COM_QUIT)
|
||||||
|
{
|
||||||
|
/** Close router session which causes closing of backends */
|
||||||
|
dcb_close(dcb);
|
||||||
}
|
}
|
||||||
|
|
||||||
return return_code;
|
return return_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user