1
0
mirror of https://github.com/MariaDB/server.git synced 2025-09-09 18:40:27 +03:00

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
This commit is contained in:
Sergey Vojtovich
2019-05-16 00:50:58 +04:00
parent 5e139437a5
commit 87775402cd
2 changed files with 17 additions and 23 deletions

View File

@@ -781,34 +781,29 @@ ha_commit_checkpoint_request(void *cookie, void (*pre_hook)(void *))
} }
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
be rolled back already
*/
if (hton->state == SHOW_OPTION_YES && thd_get_ha_data(thd, hton))
{
if (hton->close_connection)
hton->close_connection(hton, thd);
/* make sure ha_data is reset and ha_data_lock is released */
thd_set_ha_data(thd, hton, NULL);
}
return FALSE;
}
/** /**
@note @note
don't bother to rollback here, it's done already don't bother to rollback here, it's done already
there's no need to rollback here as all transactions must
be rolled back already
*/ */
void ha_close_connection(THD* thd) void ha_close_connection(THD* thd)
{ {
plugin_foreach_with_mask(thd, closecon_handlerton, for (auto i= 0; i < MAX_HA; i++)
MYSQL_STORAGE_ENGINE_PLUGIN, {
PLUGIN_IS_DELETED|PLUGIN_IS_READY, 0); if (thd->ha_data[i].lock)
{
handlerton *hton= plugin_hton(thd->ha_data[i].lock);
if (hton->close_connection)
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 */
thd_set_ha_data(thd, hton, 0);
}
DBUG_ASSERT(!thd->ha_data[i].ha_ptr);
}
} }
static my_bool kill_handlerton(THD *thd, plugin_ref plugin, static my_bool kill_handlerton(THD *thd, plugin_ref plugin,

View File

@@ -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);