From 163b34fe25919b25ff83860f30f2440b44c8b53b Mon Sep 17 00:00:00 2001 From: Monty Date: Tue, 9 Oct 2018 18:55:18 +0300 Subject: Optimize flush tables with read lock (FTWRL) to not wait for select's Part of MDEV-5336 Implement LOCK FOR BACKUP The idea is that instead of waiting in close_cached_tables() for all tables to be closed, we instead call flush_tables() that does: - Flush not used objects in table cache to free memory - Collect all tables that are open - Call HA_EXTRA_FLUSH on the objects, to get them into "closed state" - Added HA_EXTRA_FLUSH support to archive and CSV - Added multi-user protection to HA_EXTRA_FLUSH in MyISAM and Aria The benefit compared to old code is: - FTWRL doesn't have to wait for long running read operations or open HANDLER's --- sql/sql_reload.cc | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'sql/sql_reload.cc') diff --git a/sql/sql_reload.cc b/sql/sql_reload.cc index abdf9d76d15..961f31eb728 100644 --- a/sql/sql_reload.cc +++ b/sql/sql_reload.cc @@ -231,6 +231,7 @@ bool reload_acl_and_cache(THD *thd, unsigned long long options, { if ((options & REFRESH_READ_LOCK) && thd) { + DBUG_ASSERT(!(options & REFRESH_FAST) && !tables); /* On the first hand we need write lock on the tables to be flushed, on the other hand we must not try to aspire a global read lock @@ -249,9 +250,7 @@ bool reload_acl_and_cache(THD *thd, unsigned long long options, tmp_write_to_binlog= 0; if (thd->global_read_lock.lock_global_read_lock(thd)) return 1; // Killed - if (close_cached_tables(thd, tables, - ((options & REFRESH_FAST) ? FALSE : TRUE), - thd->variables.lock_wait_timeout)) + if (flush_tables(thd)) { /* NOTE: my_error() has been already called by reopen_tables() within @@ -274,11 +273,9 @@ bool reload_acl_and_cache(THD *thd, unsigned long long options, make_global_read_lock_block_commit(thd) above since they could have modified the tables too. */ - if (WSREP(thd) && - close_cached_tables(thd, tables, (options & REFRESH_FAST) ? - FALSE : TRUE, TRUE)) - result= 1; - } + if (WSREP(thd) && flush_tables(thd)) + result= 1; + } else { if (thd && thd->locked_tables_mode) -- cgit v1.2.1