Commit 87775402 authored by Sergey Vojtovich's avatar Sergey Vojtovich

Improved ha_close_connection() scalability

Rather than iterating global plugin collection, iterate THD local
collection. Removes two LOCK_plugin locks per connection.

Part of MDEV-19515 - Improve connect speed
parent 5e139437
...@@ -781,34 +781,29 @@ ha_commit_checkpoint_request(void *cookie, void (*pre_hook)(void *)) ...@@ -781,34 +781,29 @@ ha_commit_checkpoint_request(void *cookie, void (*pre_hook)(void *))
} }
/**
@note
don't bother to rollback here, it's done already
static my_bool closecon_handlerton(THD *thd, plugin_ref plugin,
void *unused)
{
handlerton *hton= plugin_hton(plugin);
/*
there's no need to rollback here as all transactions must there's no need to rollback here as all transactions must
be rolled back already be rolled back already
*/ */
if (hton->state == SHOW_OPTION_YES && thd_get_ha_data(thd, hton)) void ha_close_connection(THD* thd)
{
for (auto i= 0; i < MAX_HA; i++)
{
if (thd->ha_data[i].lock)
{ {
handlerton *hton= plugin_hton(thd->ha_data[i].lock);
if (hton->close_connection) if (hton->close_connection)
hton->close_connection(hton, thd); hton->close_connection(hton, thd);
/* make sure SE didn't reset ha_data in close_connection() */
DBUG_ASSERT(thd->ha_data[i].lock);
/* make sure ha_data is reset and ha_data_lock is released */ /* make sure ha_data is reset and ha_data_lock is released */
thd_set_ha_data(thd, hton, NULL); thd_set_ha_data(thd, hton, 0);
}
DBUG_ASSERT(!thd->ha_data[i].ha_ptr);
} }
return FALSE;
}
/**
@note
don't bother to rollback here, it's done already
*/
void ha_close_connection(THD* thd)
{
plugin_foreach_with_mask(thd, closecon_handlerton,
MYSQL_STORAGE_ENGINE_PLUGIN,
PLUGIN_IS_DELETED|PLUGIN_IS_READY, 0);
} }
static my_bool kill_handlerton(THD *thd, plugin_ref plugin, static my_bool kill_handlerton(THD *thd, plugin_ref plugin,
......
...@@ -1723,7 +1723,6 @@ static int binlog_close_connection(handlerton *hton, THD *thd) ...@@ -1723,7 +1723,6 @@ static int binlog_close_connection(handlerton *hton, THD *thd)
} }
#endif /* WITH_WSREP */ #endif /* WITH_WSREP */
DBUG_ASSERT(cache_mngr->trx_cache.empty() && cache_mngr->stmt_cache.empty()); DBUG_ASSERT(cache_mngr->trx_cache.empty() && cache_mngr->stmt_cache.empty());
thd_set_ha_data(thd, binlog_hton, NULL);
cache_mngr->~binlog_cache_mngr(); cache_mngr->~binlog_cache_mngr();
my_free(cache_mngr); my_free(cache_mngr);
DBUG_RETURN(0); DBUG_RETURN(0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment