MXS-553: Use dcb_set for KILL command handling

Now that the set of DCBs is stored in the session, it can be used to speed
up the handling of the KILL command processing by stopping when the first
related DCB is found.
This commit is contained in:
Markus Mäkelä 2018-05-18 10:18:05 +03:00
parent 643fc825fa
commit 621139f901
No known key found for this signature in database
GPG Key ID: 72D48FCE664F7B19

View File

@ -1709,26 +1709,32 @@ struct KillInfo
static bool kill_func(DCB *dcb, void *data)
{
bool rval = true;
KillInfo* info = (KillInfo*)data;
if (dcb->dcb_role == DCB_ROLE_BACKEND_HANDLER &&
dcb->session->ses_id == info->target_id)
if (dcb->session->ses_id == info->target_id)
{
MySQLProtocol* proto = (MySQLProtocol*)dcb->protocol;
for (auto it = dcb->session->dcb_set->begin(); it != dcb->session->dcb_set->end(); it++)
{
MySQLProtocol* proto = (MySQLProtocol*)(*it)->protocol;
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);
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((*it)->server, proto->thread_id));
}
else
{
// DCB is not yet connected, send a hangup to forcibly close it
poll_fake_hangup_event(*it);
}
}
// Found the session, stop iterating over DCBs
rval = false;
}
return true;
return rval;
}
void mxs_mysql_execute_kill(MXS_SESSION* issuer, uint64_t target_id, kill_type_t type)