diff options
author | Monty <monty@mariadb.org> | 2018-10-09 18:55:18 +0300 |
---|---|---|
committer | Monty <monty@mariadb.org> | 2018-12-09 22:12:25 +0200 |
commit | 163b34fe25919b25ff83860f30f2440b44c8b53b (patch) | |
tree | 7d21575247bdba318889ad4bc650028e59549781 /sql/sql_reload.cc | |
parent | 306b7a2243eb3c3e8dcc567ef6d4e7e50dca21a4 (diff) | |
download | mariadb-git-163b34fe25919b25ff83860f30f2440b44c8b53b.tar.gz |
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
Diffstat (limited to 'sql/sql_reload.cc')
-rw-r--r-- | sql/sql_reload.cc | 13 |
1 files changed, 5 insertions, 8 deletions
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) |