diff options
author | Sergey Vojtovich <svoj@mariadb.org> | 2019-05-16 00:50:58 +0400 |
---|---|---|
committer | Sergey Vojtovich <svoj@mariadb.org> | 2019-05-21 00:42:30 +0400 |
commit | 2cbbc55995d3bec07c0761b9cc22d6884e2a9e78 (patch) | |
tree | cbd716344f609a3c5c6736a64db46d50cbc98238 | |
parent | 427549d774f4a405848ad193cdf92d6a271535f5 (diff) | |
download | mariadb-git-2cbbc55995d3bec07c0761b9cc22d6884e2a9e78.tar.gz |
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
-rw-r--r-- | sql/handler.cc | 39 | ||||
-rw-r--r-- | sql/log.cc | 1 |
2 files changed, 17 insertions, 23 deletions
diff --git a/sql/handler.cc b/sql/handler.cc index f9336dfca31..22b2c0ea9e2 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -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 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) { - plugin_foreach_with_mask(thd, closecon_handlerton, - MYSQL_STORAGE_ENGINE_PLUGIN, - PLUGIN_IS_DELETED|PLUGIN_IS_READY, 0); + 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) + 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, diff --git a/sql/log.cc b/sql/log.cc index aa63736b796..22b4e1852f0 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -1723,7 +1723,6 @@ static int binlog_close_connection(handlerton *hton, THD *thd) } #endif /* WITH_WSREP */ 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(); my_free(cache_mngr); DBUG_RETURN(0); |