diff options
author | Monty <monty@mariadb.org> | 2018-10-31 22:52:29 +0200 |
---|---|---|
committer | Monty <monty@mariadb.org> | 2018-12-09 22:12:26 +0200 |
commit | 7fb9d64989ad8bb86ee47ded88dc5e2493aca4b8 (patch) | |
tree | a965ed7e10fc1bf4f0c1b052d3a653a6ec33ae47 /mysql-test/main | |
parent | 7bb3a5220e9960c5b3c0fd44d656d26d45b3cdef (diff) | |
download | mariadb-git-7fb9d64989ad8bb86ee47ded88dc5e2493aca4b8.tar.gz |
Changed FLUSH TABLES to not change share version
Part of MDEV-5336 Implement LOCK FOR BACKUP
Originally both table metadata lock and global read lock protection
were acquired before getting TABLE from table cache. This will be
reordered in a future commit with MDL_BACKUP_XXX locks so that we
first take table metadata lock, then get TABLE from table cache, then
acquire analogue of global read lock.
This patch both simplifies FLUSH TABLES code, makes FLUSH TABLES to
lock less and also enables FLUSH TABLES code to be used with backup
locks.
The usage of FLUSH TABLES changes slightly:
- FLUSH TABLES without any arguments will now only close not used tables
and tables locked by the FLUSH TABLES connection. All not used table
shares will be closed.
Tables locked by the FLUSH TABLES connection will be reopened and
re-locked after all others has stoped using the table (as before).
If there was no locked tables, then FLUSH TABLES is instant and will
not cause any waits.
FLUSH TABLES will not wait for any in use table.
- FLUSH TABLES with a table list, will ensure that the tables are closed
before statement returns. The code is now only using MDL locks and not
table share versions, which simplices the code greatly. One visible
change is that the server will wait for the end of the transaction that
are using the tables. Before FLUSH TABLES only waited for the statements
to end.
Signed-off-by: Monty <monty@mariadb.org>
Diffstat (limited to 'mysql-test/main')
-rw-r--r-- | mysql-test/main/flush.result | 16 | ||||
-rw-r--r-- | mysql-test/main/flush.test | 31 | ||||
-rw-r--r-- | mysql-test/main/information_schema.result | 1 | ||||
-rw-r--r-- | mysql-test/main/information_schema.test | 7 | ||||
-rw-r--r-- | mysql-test/main/kill.result | 2 | ||||
-rw-r--r-- | mysql-test/main/kill.test | 8 | ||||
-rw-r--r-- | mysql-test/main/lock.result | 2 | ||||
-rw-r--r-- | mysql-test/main/lock.test | 2 | ||||
-rw-r--r-- | mysql-test/main/lock_multi.result | 3 | ||||
-rw-r--r-- | mysql-test/main/lock_multi.test | 10 | ||||
-rw-r--r-- | mysql-test/main/lock_sync.result | 2 | ||||
-rw-r--r-- | mysql-test/main/lock_sync.test | 4 | ||||
-rw-r--r-- | mysql-test/main/mdl_sync.result | 3 | ||||
-rw-r--r-- | mysql-test/main/mdl_sync.test | 9 | ||||
-rw-r--r-- | mysql-test/main/truncate_coverage.result | 2 | ||||
-rw-r--r-- | mysql-test/main/truncate_coverage.test | 4 |
16 files changed, 49 insertions, 57 deletions
diff --git a/mysql-test/main/flush.result b/mysql-test/main/flush.result index c5176527a3a..8149ce29dec 100644 --- a/mysql-test/main/flush.result +++ b/mysql-test/main/flush.result @@ -364,16 +364,19 @@ flush table t1; connection default; # Let flush table sync in. select * from t1; +a connection con1; select * from t1; a unlock tables; +connection default; +select count(*) from information_schema.processlist where state = "Waiting for table metadata lock"; +count(*) +1 +commit; connection con2; # Reaping 'flush table t1'... connection default; -# Reaping 'select * from t1'... -a -commit; # # Repeat the same test but with FLUSH TABLES # @@ -386,13 +389,10 @@ connection con1; # lock table t1 read; connection con2; -# -# FLUSH TABLES expels the table definition from the cache. -# Sending 'flush tables'... flush tables; connection default; -# Let flush table sync in. select * from t1; +a connection con1; select * from t1; a @@ -400,8 +400,6 @@ unlock tables; connection con2; # Reaping 'flush tables'... connection default; -# Reaping 'select * from t1'... -a commit; # Cleanup connection con1; diff --git a/mysql-test/main/flush.test b/mysql-test/main/flush.test index d626abf8880..821168f7706 100644 --- a/mysql-test/main/flush.test +++ b/mysql-test/main/flush.test @@ -449,24 +449,20 @@ connection default; --echo # Let flush table sync in. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table flush" + where state = "Waiting for table metadata lock" and info = "flush table t1"; --source include/wait_condition.inc -send select * from t1; +select * from t1; connection con1; -let $wait_condition= - select count(*) = 1 from information_schema.processlist - where state = "Waiting for table flush" - and info = "select * from t1"; select * from t1; unlock tables; +connection default; +select count(*) from information_schema.processlist where state = "Waiting for table metadata lock"; +commit; connection con2; --echo # Reaping 'flush table t1'... reap; connection default; ---echo # Reaping 'select * from t1'... -reap; -commit; --echo # --echo # Repeat the same test but with FLUSH TABLES @@ -480,31 +476,16 @@ connection con1; --echo # lock table t1 read; connection con2; ---echo # ---echo # FLUSH TABLES expels the table definition from the cache. ---echo # Sending 'flush tables'... send flush tables; connection default; ---echo # Let flush table sync in. -let $wait_condition= - select count(*) = 1 from information_schema.processlist - where state = "Waiting for table flush" - and info = "flush tables"; ---source include/wait_condition.inc -send select * from t1; +select * from t1; connection con1; -let $wait_condition= - select count(*) = 1 from information_schema.processlist - where state = "Waiting for table flush" - and info = "select * from t1"; select * from t1; unlock tables; connection con2; --echo # Reaping 'flush tables'... reap; connection default; ---echo # Reaping 'select * from t1'... -reap; commit; --echo # Cleanup diff --git a/mysql-test/main/information_schema.result b/mysql-test/main/information_schema.result index 4a39eea6115..6db839edf51 100644 --- a/mysql-test/main/information_schema.result +++ b/mysql-test/main/information_schema.result @@ -1957,6 +1957,7 @@ lock table t1 read; connect con1, localhost, root,,; connection con1; flush tables; +flush tables t1; connection default; select * from information_schema.views; TABLE_CATALOG def diff --git a/mysql-test/main/information_schema.test b/mysql-test/main/information_schema.test index 2b318f5f1aa..7ce6437d610 100644 --- a/mysql-test/main/information_schema.test +++ b/mysql-test/main/information_schema.test @@ -1622,12 +1622,13 @@ alter table t1 change b c int; lock table t1 read; connect(con1, localhost, root,,); connection con1; -send flush tables; +flush tables; +send flush tables t1; connection default; let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table flush" and - info = "flush tables"; + where state = "Waiting for table metadata lock" and + info = "flush tables t1"; --source include/wait_condition.inc --vertical_results select * from information_schema.views; diff --git a/mysql-test/main/kill.result b/mysql-test/main/kill.result index dc1cb9252da..4775d111b79 100644 --- a/mysql-test/main/kill.result +++ b/mysql-test/main/kill.result @@ -324,7 +324,7 @@ connection blocker; lock tables t1 read; connection ddl; # Let us mark locked table t1 as old -flush tables; +flush tables t1; connection dml; select * from t1; connection default; diff --git a/mysql-test/main/kill.test b/mysql-test/main/kill.test index b6000ffced1..059d8d40b11 100644 --- a/mysql-test/main/kill.test +++ b/mysql-test/main/kill.test @@ -538,18 +538,18 @@ connection blocker; lock tables t1 read; connection ddl; --echo # Let us mark locked table t1 as old ---send flush tables +--send flush tables t1 connection dml; let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table flush" and - info = "flush tables"; + where state = "Waiting for table metadata lock" and + info = "flush tables t1"; --source include/wait_condition.inc --send select * from t1 connection default; let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table flush" and + where state = "Waiting for table metadata lock" and info = "select * from t1"; --source include/wait_condition.inc --replace_result $ID2 ID2 diff --git a/mysql-test/main/lock.result b/mysql-test/main/lock.result index c49b7141634..6edb86bfa3f 100644 --- a/mysql-test/main/lock.result +++ b/mysql-test/main/lock.result @@ -500,7 +500,7 @@ connect con1,localhost,root,,test; LOCK TABLE t2 WRITE; SET lock_wait_timeout= 1; FLUSH TABLES; -ERROR HY000: Lock wait timeout exceeded; try restarting transaction +FLUSH TABLES t2; UNLOCK TABLES; disconnect con1; connection default; diff --git a/mysql-test/main/lock.test b/mysql-test/main/lock.test index ff77b4991c0..8a59f4082b1 100644 --- a/mysql-test/main/lock.test +++ b/mysql-test/main/lock.test @@ -609,8 +609,8 @@ LOCK TABLE t1 READ; --connect (con1,localhost,root,,test) LOCK TABLE t2 WRITE; SET lock_wait_timeout= 1; ---error ER_LOCK_WAIT_TIMEOUT FLUSH TABLES; +FLUSH TABLES t2; # Cleanup UNLOCK TABLES; diff --git a/mysql-test/main/lock_multi.result b/mysql-test/main/lock_multi.result index 52b4608fdd2..1d9528764df 100644 --- a/mysql-test/main/lock_multi.result +++ b/mysql-test/main/lock_multi.result @@ -531,8 +531,9 @@ connect con3, localhost, root; connection default; LOCK TABLE t1 READ; connection con3; -# Sending: FLUSH TABLES; +# Sending: +FLUSH TABLES t1; connection con2; SELECT * FROM t1; ERROR HY000: Lock wait timeout exceeded; try restarting transaction diff --git a/mysql-test/main/lock_multi.test b/mysql-test/main/lock_multi.test index ce901126ce5..3167e6d82d6 100644 --- a/mysql-test/main/lock_multi.test +++ b/mysql-test/main/lock_multi.test @@ -931,13 +931,19 @@ connection default; LOCK TABLE t1 READ; connection con3; + +# first test that flush tables doesn't block +FLUSH TABLES; + +# Check the FLUSH TABLES t1 waits until table lock is released + --echo # Sending: ---send FLUSH TABLES +--send FLUSH TABLES t1 connection con2; let $wait_condition= SELECT COUNT(*) = 1 FROM information_schema.processlist - WHERE state = "Waiting for table flush" AND info = "FLUSH TABLES"; + WHERE state = "Waiting for table metadata lock" AND info = "FLUSH TABLES t1"; --source include/wait_condition.inc --error ER_LOCK_WAIT_TIMEOUT SELECT * FROM t1; diff --git a/mysql-test/main/lock_sync.result b/mysql-test/main/lock_sync.result index 93182399958..bbdc1d43ba5 100644 --- a/mysql-test/main/lock_sync.result +++ b/mysql-test/main/lock_sync.result @@ -782,7 +782,7 @@ SET DEBUG_SYNC= 'now WAIT_FOR opened'; SET DEBUG_SYNC= 'now SIGNAL dropped'; SET DEBUG_SYNC= 'now WAIT_FOR opened'; # Sending: -FLUSH TABLES; +FLUSH TABLES t1; connection default; # Waiting for FLUSH TABLES to be blocked. SET DEBUG_SYNC= 'now SIGNAL dropped'; diff --git a/mysql-test/main/lock_sync.test b/mysql-test/main/lock_sync.test index af8435f7fbb..1a8cd7bdbd3 100644 --- a/mysql-test/main/lock_sync.test +++ b/mysql-test/main/lock_sync.test @@ -974,12 +974,12 @@ SET DEBUG_SYNC= 'now WAIT_FOR opened'; SET DEBUG_SYNC= 'now SIGNAL dropped'; SET DEBUG_SYNC= 'now WAIT_FOR opened'; --echo # Sending: ---send FLUSH TABLES +--send FLUSH TABLES t1 connection default; --echo # Waiting for FLUSH TABLES to be blocked. let $wait_condition= SELECT COUNT(*)=1 FROM information_schema.processlist - WHERE state= 'Waiting for table flush' AND info= 'FLUSH TABLES'; + WHERE state= 'Waiting for table metadata lock' AND info= 'FLUSH TABLES t1'; --source include/wait_condition.inc SET DEBUG_SYNC= 'now SIGNAL dropped'; diff --git a/mysql-test/main/mdl_sync.result b/mysql-test/main/mdl_sync.result index bf659a3616f..7e90720dca5 100644 --- a/mysql-test/main/mdl_sync.result +++ b/mysql-test/main/mdl_sync.result @@ -2146,10 +2146,11 @@ flush tables t1, t2 with read lock; connection con1; # Wait till FLUSH TABLES <list> WITH READ LOCK stops. set debug_sync='now WAIT_FOR parked'; +flush tables; # Start a statement which will flush all tables and thus # invalidate table t1 open by FLUSH TABLES <list> WITH READ LOCK. # Sending: -flush tables; +flush tables t1; connection default; # Wait till the above FLUSH TABLES blocks. # Resume FLUSH TABLES <list> WITH READ LOCK, so it tries to open t2 diff --git a/mysql-test/main/mdl_sync.test b/mysql-test/main/mdl_sync.test index 20f850a2744..31b2885ae45 100644 --- a/mysql-test/main/mdl_sync.test +++ b/mysql-test/main/mdl_sync.test @@ -2690,17 +2690,20 @@ connection con1; --echo # Wait till FLUSH TABLES <list> WITH READ LOCK stops. set debug_sync='now WAIT_FOR parked'; +# Simple flush tables should not block +flush tables; + --echo # Start a statement which will flush all tables and thus --echo # invalidate table t1 open by FLUSH TABLES <list> WITH READ LOCK. --echo # Sending: -send flush tables; +send flush tables t1; connection default; --echo # Wait till the above FLUSH TABLES blocks. let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table flush" and - info = "flush tables"; + where state = "Waiting for table metadata lock" and + info = "flush tables t1"; --source include/wait_condition.inc --echo # Resume FLUSH TABLES <list> WITH READ LOCK, so it tries to open t2 diff --git a/mysql-test/main/truncate_coverage.result b/mysql-test/main/truncate_coverage.result index 078de1ef3ab..9a343832b69 100644 --- a/mysql-test/main/truncate_coverage.result +++ b/mysql-test/main/truncate_coverage.result @@ -40,7 +40,7 @@ TRUNCATE TABLE m1; connection con2; SET DEBUG_SYNC= 'now WAIT_FOR opened'; # Sending: -FLUSH TABLES; +FLUSH TABLES m1; connection default; # Waiting for FLUSH TABLES to be blocked. SET DEBUG_SYNC= 'now SIGNAL dropped'; diff --git a/mysql-test/main/truncate_coverage.test b/mysql-test/main/truncate_coverage.test index 3351ce84232..1b793c6638c 100644 --- a/mysql-test/main/truncate_coverage.test +++ b/mysql-test/main/truncate_coverage.test @@ -81,12 +81,12 @@ SET DEBUG_SYNC= 'open_tables_after_open_and_process_table SIGNAL opened WAIT_FOR connection con2; SET DEBUG_SYNC= 'now WAIT_FOR opened'; --echo # Sending: ---send FLUSH TABLES +--send FLUSH TABLES m1 connection default; --echo # Waiting for FLUSH TABLES to be blocked. let $wait_condition= SELECT COUNT(*)=1 FROM information_schema.processlist - WHERE state= 'Waiting for table flush' AND info= 'FLUSH TABLES'; + WHERE state= 'Waiting for table metadata lock' AND info= 'FLUSH TABLES m1'; --source include/wait_condition.inc SET DEBUG_SYNC= 'now SIGNAL dropped'; |