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 --- mysql-test/main/mdl_sync.result | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'mysql-test/main/mdl_sync.result') diff --git a/mysql-test/main/mdl_sync.result b/mysql-test/main/mdl_sync.result index 3880fc5ef91..bf659a3616f 100644 --- a/mysql-test/main/mdl_sync.result +++ b/mysql-test/main/mdl_sync.result @@ -3055,7 +3055,7 @@ disconnect con3; # CREATE TABLE t1(a INT) ENGINE=InnoDB; SET debug_sync='open_tables_after_open_and_process_table SIGNAL ready WAIT_FOR go'; -SELECT * FROM t1; +INSERT INTO t1 values (1); connect con1,localhost,root,,; SET debug_sync='now WAIT_FOR ready'; SET lock_wait_timeout=1; @@ -3063,7 +3063,21 @@ FLUSH TABLES WITH READ LOCK; ERROR HY000: Lock wait timeout exceeded; try restarting transaction SET debug_sync='now SIGNAL go'; connection default; +# After MDEV-5536, SELECT will not block FLUSH TABLES +SET debug_sync='RESET'; +SET debug_sync='open_tables_after_open_and_process_table SIGNAL ready WAIT_FOR go'; +SELECT * FROM t1; +connection con1; +SET debug_sync='now WAIT_FOR ready'; +SET lock_wait_timeout=1; +FLUSH TABLES WITH READ LOCK; +SET debug_sync='now SIGNAL go'; +connection default; a +1 +connection con1; +unlock tables; +connection default; SET debug_sync='RESET'; DROP TABLE t1; disconnect con1; -- cgit v1.2.1