MXS-1852: Close partially connected DCBs if killed

If a connection is killed but the backend DCBs have not yet received their
thread IDs, the connections can be forcibly closed. This removes the
possibility of stale connections caused by an unfortunately timed KILL
query to a session that has partially connected to some servers.
This commit is contained in:
Markus Mäkelä 2018-05-08 10:25:12 +03:00
parent 39789c19d3
commit dbbd0e957a
No known key found for this signature in database
GPG Key ID: 72D48FCE664F7B19

View File

@ -29,6 +29,7 @@
#include <maxscale/protocol/mysql.h>
#include <maxscale/utils.h>
#include <maxscale/protocol/mariadb_client.hh>
#include <maxscale/poll.h>
uint8_t null_client_sha1[MYSQL_SCRAMBLE_LEN] = "";
@ -1694,7 +1695,17 @@ static bool kill_func(DCB *dcb, void *data)
dcb->session->ses_id == info->target_id)
{
MySQLProtocol* proto = (MySQLProtocol*)dcb->protocol;
info->targets.push_back(std::make_pair(dcb->server, proto->thread_id));
if (proto->thread_id)
{
// DCB is connected and we know the thread ID so we can kill it
info->targets.push_back(std::make_pair(dcb->server, proto->thread_id));
}
else
{
// DCB is not yet connected, send a hangup to forcibly close it
poll_fake_hangup_event(dcb);
}
}
return true;