Commit a6c00c27 authored by Dmitry Lenev's avatar Dmitry Lenev

Part of fix for bug#52044 "FLUSH TABLES WITH READ LOCK and

FLUSH TABLES <list> WITH READ LOCK are incompatible" to
be pushed as separate patch.

Replaced thread state name "Waiting for table", which was
used by threads waiting for a metadata lock or table flush, 
with a set of names which better reflect types of resources
being waited for.

Also replaced "Table lock" thread state name, which was used 
by threads waiting on thr_lock.c table level lock, with more
elaborate "Waiting for table level lock", to make it 
more consistent with other thread state names.

Updated test cases and their results according to these 
changes.

Fixed sys_vars.query_cache_wlock_invalidate_func test to not
to wait for timeout of wait_condition.inc script.
parent 6a447d10
......@@ -153,7 +153,7 @@ connection master;
let $wait_condition=
SELECT COUNT(*) = 1 FROM information_schema.processlist
WHERE info = "RENAME TABLE t1 TO t3, t2 TO t1" and
state = "Waiting for table";
state = "Waiting for table metadata lock";
--source include/wait_condition.inc
COMMIT;
......
......@@ -43,7 +43,8 @@ connection default;
# of our statement.
let $wait_condition=
select count(*) = 1 from information_schema.processlist
where state = "Table lock" and info = "insert into $table (i) values (0)";
where state = "Waiting for table level lock" and
info = "insert into $table (i) values (0)";
--source include/wait_condition.inc
--disable_result_log
......
......@@ -557,7 +557,8 @@ connection waiter;
--echo connection: waiter
let $wait_condition=
select count(*) = 1 from information_schema.processlist
where state = "Waiting for table" and info = "rename table t1 to t0";
where state = "Waiting for table metadata lock" and
info = "rename table t1 to t0";
--source include/wait_condition.inc
connection default;
--echo connection: default
......@@ -743,7 +744,8 @@ send alter table t1 engine=memory;
connection con2;
let $wait_condition=
select count(*) = 1 from information_schema.processlist
where state = "Waiting for table" and info = "alter table t1 engine=memory";
where state = "Waiting for table metadata lock" and
info = "alter table t1 engine=memory";
--source include/wait_condition.inc
connection default;
--error ER_ILLEGAL_HA
......@@ -764,7 +766,8 @@ send alter table t1 engine=memory;
connection con2;
let $wait_condition=
select count(*) = 1 from information_schema.processlist
where state = "Waiting for table" and info = "alter table t1 engine=memory";
where state = "Waiting for table metadata lock" and
info = "alter table t1 engine=memory";
--source include/wait_condition.inc
connection default;
--echo # Since S metadata lock was already acquired at HANDLER OPEN time
......@@ -1024,7 +1027,9 @@ connection con1;
--echo # --> connection con2
connection con2;
--echo # Waitng for 'drop table t1' to get blocked...
let $wait_condition=select count(*)=1 from information_schema.processlist where state='Waiting for table' and info='drop table t1';
let $wait_condition=select count(*)=1 from information_schema.processlist
where state='Waiting for table metadata lock' and
info='drop table t1';
--source include/wait_condition.inc
--echo # --> connection default
connection default;
......@@ -1055,7 +1060,9 @@ connection con1;
--echo # --> connection con2
connection con2;
--echo # Waiting for 'drop table t1' to get blocked...
let $wait_condition=select count(*)=1 from information_schema.processlist where state='Waiting for table' and info='drop table t1';
let $wait_condition=select count(*)=1 from information_schema.processlist
where state='Waiting for table metadata lock' and
info='drop table t1';
--source include/wait_condition.inc
--echo # --> connection default
connection default;
......@@ -1097,7 +1104,8 @@ send rename table t0 to t3, t1 to t0, t3 to t1;
connection con1;
--echo # Waiting for 'rename table ...' to get blocked...
let $wait_condition=select count(*)=1 from information_schema.processlist
where state='Waiting for table' and info='rename table t0 to t3, t1 to t0, t3 to t1';
where state='Waiting for table metadata lock' and
info='rename table t0 to t3, t1 to t0, t3 to t1';
--source include/wait_condition.inc
--echo # --> connection default
connection default;
......@@ -1137,7 +1145,9 @@ connection con2;
--echo # --> connection con1
connection con1;
--echo # Waiting for 'drop table t2' to get blocked...
let $wait_condition=select count(*)=1 from information_schema.processlist where state='Waiting for table' and info='drop table t2';
let $wait_condition=select count(*)=1 from information_schema.processlist
where state='Waiting for table metadata lock' and
info='drop table t2';
--source include/wait_condition.inc
--echo # --> connection default
connection default;
......@@ -1146,7 +1156,9 @@ send select * from t2;
--echo # --> connection con1
connection con1;
--echo # Waiting for 'select * from t2' to get blocked...
let $wait_condition=select count(*)=1 from information_schema.processlist where state='Waiting for table' and info='select * from t2';
let $wait_condition=select count(*)=1 from information_schema.processlist
where state='Waiting for table metadata lock' and
info='select * from t2';
unlock tables;
--echo # --> connection con2
connection con2;
......@@ -1190,10 +1202,14 @@ connection default;
--echo # --> connection con3
connection con3;
--echo # Waiting for 'drop table t1' to get blocked...
let $wait_condition=select count(*)=1 from information_schema.processlist where state='Waiting for table' and info='drop table t1';
let $wait_condition=select count(*)=1 from information_schema.processlist
where state='Waiting for table metadata lock' and
info='drop table t1';
--source include/wait_condition.inc
--echo # Waiting for 'drop table t2' to get blocked...
let $wait_condition=select count(*)=1 from information_schema.processlist where state='Waiting for table' and info='drop table t2';
let $wait_condition=select count(*)=1 from information_schema.processlist
where state='Waiting for table metadata lock' and
info='drop table t2';
--source include/wait_condition.inc
--echo # Demonstrate that t2 lock was released and t2 was dropped
--echo # after ROLLBACK TO SAVEPOINT
......@@ -1255,10 +1271,14 @@ connection default;
--echo # --> connection con3
connection con3;
--echo # Waiting for 'drop table t1' to get blocked...
let $wait_condition=select count(*)=1 from information_schema.processlist where state='Waiting for table' and info='drop table t1';
let $wait_condition=select count(*)=1 from information_schema.processlist
where state='Waiting for table metadata lock' and
info='drop table t1';
--source include/wait_condition.inc
--echo # Waiting for 'drop table t2' to get blocked...
let $wait_condition=select count(*)=1 from information_schema.processlist where state='Waiting for table' and info='drop table t2';
let $wait_condition=select count(*)=1 from information_schema.processlist
where state='Waiting for table metadata lock' and
info='drop table t2';
--source include/wait_condition.inc
--echo # Demonstrate that t2 lock was released and t2 was dropped
--echo # after ROLLBACK TO SAVEPOINT
......@@ -1314,7 +1334,9 @@ drop table t1, t2;
--echo # --> connection con2
connection con2;
--echo # Waiting for 'drop table t3' to get blocked...
let $wait_condition=select count(*)=1 from information_schema.processlist where state='Waiting for table' and info='drop table t3';
let $wait_condition=select count(*)=1 from information_schema.processlist
where state='Waiting for table metadata lock' and
info='drop table t3';
--source include/wait_condition.inc
--echo # Demonstrate that ROLLBACK TO SAVEPOINT didn't release the handler
--echo # lock.
......@@ -1348,7 +1370,9 @@ send drop table t2;
--echo # --> connection con2
connection con2;
--echo # Waiting for 'drop table t2' to get blocked...
let $wait_condition=select count(*)=1 from information_schema.processlist where state='Waiting for table' and info='drop table t2';
let $wait_condition=select count(*)=1 from information_schema.processlist
where state='Waiting for table metadata lock' and
info='drop table t2';
--source include/wait_condition.inc
--echo # --> connection con1
connection con1;
......@@ -1400,7 +1424,8 @@ connection con2;
--echo # has read from the table commits.
let $wait_condition=
select count(*) = 1 from information_schema.processlist
where state = "Waiting for table" and info = "lock tables t1 write";
where state = "Waiting for table metadata lock" and
info = "lock tables t1 write";
--source include/wait_condition.inc
--echo # --> connection default
......@@ -1427,7 +1452,8 @@ connection con1;
--echo # Waiting for 'handler t1 read a next' to get blocked...
let $wait_condition=
select count(*) = 1 from information_schema.processlist
where state = "Table lock" and info = "handler t1 read a next";
where state = "Waiting for table level lock" and
info = "handler t1 read a next";
--source include/wait_condition.inc
--echo # The below 'drop table t1' should be able to proceed without
......
......@@ -1583,7 +1583,7 @@ connect (con1, localhost, root,,);
--echo # Connection default
connection default;
let $wait_condition= SELECT COUNT(*)=1 FROM information_schema.processlist
WHERE state='Waiting for table' AND info='TRUNCATE TABLE t1';
WHERE state='Waiting for table metadata lock' AND info='TRUNCATE TABLE t1';
--source include/wait_condition.inc
SELECT * FROM t1 ORDER BY a;
ROLLBACK;
......
......@@ -701,6 +701,7 @@ drop table t1,t2,t3,t4;
set query_cache_wlock_invalidate=1;
create table t1 (a int not null);
create table t2 (a int not null);
create view v1 as select * from t1;
select * from t1;
a
select * from t2;
......@@ -713,6 +714,17 @@ show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 1
unlock table;
select * from t1;
a
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 2
lock table v1 write;
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 2
unlock table;
drop view v1;
drop table t1,t2;
set query_cache_wlock_invalidate=default;
CREATE TABLE t1 (id INT PRIMARY KEY);
......@@ -853,7 +865,7 @@ Variable_name Value
Qcache_queries_in_cache 0
show status like "Qcache_inserts";
Variable_name Value
Qcache_inserts 18
Qcache_inserts 19
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 6
......@@ -866,7 +878,7 @@ Variable_name Value
Qcache_queries_in_cache 1
show status like "Qcache_inserts";
Variable_name Value
Qcache_inserts 19
Qcache_inserts 20
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 7
......
......@@ -148,12 +148,12 @@ f1()
# Sending 'drop procedure p1'...
drop procedure p1;
# --> connection con2
# Waitng for 'drop procedure t1' to get blocked on MDL lock...
# Waiting for 'drop procedure t1' to get blocked on MDL lock...
# Demonstrate that there is a pending exclusive lock.
# Sending 'select f1()'...
select f1();
# --> connection con3
# Waitng for 'select f1()' to get blocked by a pending MDL lock...
# Waiting for 'select f1()' to get blocked by a pending MDL lock...
# --> connection default
commit;
# --> connection con1
......@@ -174,12 +174,12 @@ f1()
# Sending 'create procedure p1'...
create procedure p1() begin end;
# --> connection con2
# Waitng for 'create procedure t1' to get blocked on MDL lock...
# Waiting for 'create procedure t1' to get blocked on MDL lock...
# Demonstrate that there is a pending exclusive lock.
# Sending 'select f1()'...
select f1();
# --> connection con3
# Waitng for 'select f1()' to get blocked by a pending MDL lock...
# Waiting for 'select f1()' to get blocked by a pending MDL lock...
# --> connection default
commit;
# --> connection con1
......@@ -200,12 +200,12 @@ f1()
# Sending 'alter procedure p1'...
alter procedure p1 contains sql;
# --> connection con2
# Waitng for 'alter procedure t1' to get blocked on MDL lock...
# Waiting for 'alter procedure t1' to get blocked on MDL lock...
# Demonstrate that there is a pending exclusive lock.
# Sending 'select f1()'...
select f1();
# --> connection con3
# Waitng for 'select f1()' to get blocked by a pending MDL lock...
# Waiting for 'select f1()' to get blocked by a pending MDL lock...
# --> connection default
commit;
# --> connection con1
......@@ -226,12 +226,12 @@ f1()
# Sending 'drop function f1'...
drop function f1;
# --> connection con2
# Waitng for 'drop function f1' to get blocked on MDL lock...
# Waiting for 'drop function f1' to get blocked on MDL lock...
# Demonstrate that there is a pending exclusive lock.
# Sending 'select f1()'...
select f1();
# --> connection con3
# Waitng for 'select f1()' to get blocked by a pending MDL lock...
# Waiting for 'select f1()' to get blocked by a pending MDL lock...
# --> connection default
commit;
# --> connection con1
......@@ -252,12 +252,12 @@ f1()
# Sending 'create function f1'...
create function f1() returns int return 2;
# --> connection con2
# Waitng for 'create function f1' to get blocked on MDL lock...
# Waiting for 'create function f1' to get blocked on MDL lock...
# Demonstrate that there is a pending exclusive lock.
# Sending 'select f1()'...
select f1();
# --> connection con3
# Waitng for 'select f1()' to get blocked by a pending MDL lock...
# Waiting for 'select f1()' to get blocked by a pending MDL lock...
# --> connection default
commit;
# --> connection con1
......@@ -279,12 +279,12 @@ f1()
# Sending 'alter function f1'...
alter function f1 contains sql;
# --> connection con2
# Waitng for 'alter function f1' to get blocked on MDL lock...
# Waiting for 'alter function f1' to get blocked on MDL lock...
# Demonstrate that there is a pending exclusive lock.
# Sending 'select f1()'...
select f1();
# --> connection con3
# Waitng for 'select f1()' to get blocked by a pending MDL lock...
# Waiting for 'select f1()' to get blocked by a pending MDL lock...
# --> connection default
commit;
# --> connection con1
......@@ -360,7 +360,7 @@ insert into t1 (a) values (1);
# Sending 'drop function f1'
drop function f1;
# --> connection con2
# Waitng for 'drop function f1' to get blocked on MDL lock...
# Waiting for 'drop function f1' to get blocked on MDL lock...
# --> connnection default
commit;
# --> connection con1
......@@ -379,7 +379,7 @@ a
# Sending 'drop function f1'
drop function f1;
# --> connection con2
# Waitng for 'drop function f1' to get blocked on MDL lock...
# Waiting for 'drop function f1' to get blocked on MDL lock...
# --> connnection default
commit;
# --> connection con1
......@@ -403,7 +403,7 @@ a
# Sending 'drop procedure p1'
drop procedure p1;
# --> connection con2
# Waitng for 'drop procedure p1' to get blocked on MDL lock...
# Waiting for 'drop procedure p1' to get blocked on MDL lock...
# --> connnection default
commit;
# --> connection con1
......@@ -424,7 +424,7 @@ insert into t1 (a) values (3);
# Sending 'drop function f2'
drop function f2;
# --> connection con2
# Waitng for 'drop function f2' to get blocked on MDL lock...
# Waiting for 'drop function f2' to get blocked on MDL lock...
# --> connnection default
commit;
# --> connection con1
......@@ -479,11 +479,11 @@ f2()
# Sending 'drop function f1'...
drop function f1;
# --> connection con2
# Waitng for 'drop function f1' to get blocked on MDL lock...
# Waiting for 'drop function f1' to get blocked on MDL lock...
# Sending 'drop function f2'...
drop function f2;
# --> connection default
# Waitng for 'drop function f2' to get blocked on MDL lock...
# Waiting for 'drop function f2' to get blocked on MDL lock...
rollback to savepoint sv;
# --> connection con2
# Reaping 'drop function f2'...
......@@ -537,10 +537,10 @@ f1()
# Sending 'alter function f1 ...'...
alter function f1 comment "comment";
# --> connection con2
# Waitng for 'alter function f1 ...' to get blocked on MDL lock...
# Waiting for 'alter function f1 ...' to get blocked on MDL lock...
# Sending 'call p1()'...
call p1();
# Waitng for 'call p1()' to get blocked on MDL lock on f1...
# Waiting for 'call p1()' to get blocked on MDL lock on f1...
# Let 'alter function f1 ...' go through...
commit;
# --> connection con1
......@@ -573,7 +573,7 @@ f1()
# Sending 'alter function f1 ...'...
alter function f1 comment "comment";
# --> connection con2
# Waitng for 'alter function f1 ...' to get blocked on MDL lock...
# Waiting for 'alter function f1 ...' to get blocked on MDL lock...
#
# We just mention p1() in the body of f2() to make
# sure that p1() is prelocked for f2().
......@@ -595,7 +595,7 @@ select f2() into @var;
end|
# Sending 'call p1()'...
call p1();
# Waitng for 'call p1()' to get blocked on MDL lock on f1...
# Waiting for 'call p1()' to get blocked on MDL lock on f1...
# Let 'alter function f1 ...' go through...
commit;
# --> connection con1
......@@ -634,7 +634,7 @@ get_lock("30977", 0)
# Sending 'select f3()'...
select f3();
# --> connection con1
# Waitng for 'select f3()' to get blocked on the user level lock...
# Waiting for 'select f3()' to get blocked on the user level lock...
# Do something to change the cache version.
create function f4() returns int return 4;
drop function f4;
......
......@@ -35,7 +35,7 @@ call bug9486();
show processlist;
Id User Host db Command Time State Info
# root localhost test Sleep # NULL
# root localhost test Query # Waiting for table update t1, t2 set val= 1 where id1=id2
# root localhost test Query # Waiting for table metadata lock update t1, t2 set val= 1 where id1=id2
# root localhost test Query # NULL show processlist
# root localhost test Sleep # NULL
unlock tables;
......
......@@ -60,7 +60,7 @@ let $wait_condition=
--echo # con1
let $wait_condition=
SELECT COUNT(*) = 1 FROM information_schema.processlist WHERE
state = "Table lock" and info = "INSERT INTO t2 VALUES (3)";
state = "Waiting for table level lock" and info = "INSERT INTO t2 VALUES (3)";
--source include/wait_condition.inc
SELECT RELEASE_LOCK('Bug#34306');
--connection con2
......
......@@ -367,14 +367,14 @@ echo
;
connection default;
echo
# Poll till INFO is no more NULL and State = 'Waiting for table'.
# Poll till INFO is no more NULL and State = 'Waiting for table metadata lock'.
;
let $wait_condition= SELECT COUNT(*) FROM INFORMATION_SCHEMA.PROCESSLIST
WHERE INFO IS NOT NULL AND STATE = 'Waiting for table';
WHERE INFO IS NOT NULL AND STATE = 'Waiting for table metadata lock';
--source include/wait_condition.inc
#
# Expect to see the state 'Waiting for table' for the third connection because the SELECT
# collides with the WRITE TABLE LOCK.
# Expect to see the state 'Waiting for table metadata lock' for the third
# connection because the SELECT collides with the WRITE TABLE LOCK.
--replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME>
SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
UNLOCK TABLES;
......@@ -422,10 +422,10 @@ echo
;
connection default;
echo
# Poll till INFO is no more NULL and State = 'Waiting for table'.
# Poll till INFO is no more NULL and State = 'Waiting for table metadata lock'.
;
let $wait_condition= SELECT COUNT(*) FROM INFORMATION_SCHEMA.PROCESSLIST
WHERE INFO IS NOT NULL AND STATE = 'Waiting for table';
WHERE INFO IS NOT NULL AND STATE = 'Waiting for table metadata lock';
--source include/wait_condition.inc
echo
# Expect result:
......
......@@ -87,7 +87,8 @@ connection con1;
--echo # Wait until LOCK TABLE is blocked on SQL-level lock.
let $wait_condition=
select count(*) = 1 from information_schema.processlist
where state = "Waiting for table" and info = "lock table t1 write";
where state = "Waiting for table metadata lock" and
info = "lock table t1 write";
--source include/wait_condition.inc
--echo # We should be able to do UPDATEs and SELECTs within transaction.
update t1 set x=1 where id = 0;
......
......@@ -30,7 +30,7 @@ connection master1;
connection master;
let $wait_condition=
SELECT COUNT(*) = 1 FROM information_schema.processlist
WHERE state = "Waiting for table" AND info = "DROP TABLE tt";
WHERE state = "Waiting for table metadata lock" AND info = "DROP TABLE tt";
--source include/wait_condition.inc
ROLLBACK TO SAVEPOINT insert_statement;
COMMIT;
......
......@@ -655,7 +655,8 @@ connection master;
connection master1;
--echo # Waitng for 'insert into t1 ...' to get blocked on table lock...
let $wait_condition=select count(*)=1 from information_schema.processlist
where state='Waiting for table' and info='insert into t1 (a) values (f1())';
where state='Waiting for table metadata lock' and
info='insert into t1 (a) values (f1())';
--source include/wait_condition.inc
--echo # Sending 'drop function f1'. It will wait till insert finishes.
--send drop function f1;
......@@ -663,7 +664,7 @@ where state='Waiting for table' and info='insert into t1 (a) values (f1())';
connection default;
--echo # Check that 'drop function f1' gets blocked.
let $wait_condition=select count(*)=1 from information_schema.processlist
where state='Waiting for table' and info='drop function f1';
where state='Waiting for stored function metadata lock' and info='drop function f1';
--source include/wait_condition.inc
--echo # Now let's let 'insert' go through...
unlock tables;
......
......@@ -56,7 +56,7 @@ let $wait_condition=
connection master;
let $wait_condition=
select count(*) = 1 from information_schema.processlist
where state = "Waiting for table" and info = "drop view v1";
where state = "Waiting for table metadata lock" and info = "drop view v1";
--source include/wait_condition.inc
select release_lock("lock_bg25144");
......@@ -106,7 +106,7 @@ let $wait_condition=
connection master;
let $wait_condition=
select count(*) = 1 from information_schema.processlist
where state = "Waiting for table" and
where state = "Waiting for table metadata lock" and
info = "alter view v1 as select * from t2";
--source include/wait_condition.inc
......
......@@ -37,9 +37,9 @@ INSERT INTO t1(name) VALUES('Record_7');
connection default;
## show processlist info and state ##
SELECT state,info FROM INFORMATION_SCHEMA.PROCESSLIST
WHERE state= "Table lock" AND info LIKE "INSERT INTO t1%";
WHERE state= "Waiting for table level lock" AND info LIKE "INSERT INTO t1%";
state info
Table lock INSERT INTO t1(name) VALUES('Record_7')
Waiting for table level lock INSERT INTO t1(name) VALUES('Record_7')
## table contents befor UNLOCK ##
SELECT * FROM t1;
name
......
......@@ -11,7 +11,6 @@ CREATE TABLE t1(id int, value varchar(10));
INSERT INTO t1 VALUES(1, 'val1');
INSERT INTO t1 VALUES(2, 'val2');
INSERT INTO t1 VALUES(3, 'val3');
CREATE VIEW v1 AS SELECT * FROM t1;
SET GLOBAL query_cache_size = 131072;
FLUSHING CACHE
SET GLOBAL query_cache_size = 0;
......@@ -33,11 +32,11 @@ SHOW STATUS LIKE 'Qcache_queries_in_cache';
Variable_name Value
Qcache_queries_in_cache 1
1 Expected
LOCK TABLE v1 WRITE;
LOCK TABLE t1 WRITE;
UNLOCK TABLES;
SHOW STATUS LIKE 'Qcache_queries_in_cache';
Variable_name Value
Qcache_queries_in_cache 1
Qcache_queries_in_cache 0
0 Expected
'#----------------------------FN_DYNVARS_136_02-----------------------#'
SELECT * FROM t1;
......@@ -49,13 +48,12 @@ id value
2 val2
3 val3
** Connection con0 **
LOCK TABLE v1 WRITE;
LOCK TABLE t1 WRITE;
** Connection con1 **
** Asynchronous Execution **
SELECT * FROM t1;
** Connection con0 **
wait until table is locked
Timeout in wait_condition.inc for SELECT count(*) > 0 FROM information_schema.processlist WHERE state= 'Table lock'
UNLOCK TABLES;
** Connection con1 **
** Asynchronous Result **
......@@ -79,7 +77,7 @@ SHOW STATUS LIKE 'Qcache_queries_in_cache';
Variable_name Value
Qcache_queries_in_cache 1
1 Expected
LOCK TABLE v1 WRITE;
LOCK TABLE t1 WRITE;
UNLOCK TABLES;
SHOW STATUS LIKE 'Qcache_queries_in_cache';
Variable_name Value
......@@ -102,7 +100,7 @@ id value
2 val2
3 val3
** Connection con0 **
LOCK TABLE v1 WRITE;
LOCK TABLE t1 WRITE;
** Connection con1 **
** Should not be blocked **
SELECT * FROM t1;
......@@ -165,4 +163,3 @@ SET @@GLOBAL.query_cache_type = @old_cache_type;
** Connection default **
Disconnecting Connections con0, con1
DROP TABLE t1;
DROP VIEW v1;
......@@ -98,12 +98,13 @@ INSERT INTO t1(name) VALUES('Record_7');
connection default;
# wait until INSERT will be locked (low performance)
let $wait_condition= SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST
WHERE state= "Table lock" AND info LIKE "INSERT INTO t1%";
WHERE state= "Waiting for table level lock" AND
info LIKE "INSERT INTO t1%";
--source include/wait_condition.inc
--echo ## show processlist info and state ##
SELECT state,info FROM INFORMATION_SCHEMA.PROCESSLIST
WHERE state= "Table lock" AND info LIKE "INSERT INTO t1%";
WHERE state= "Waiting for table level lock" AND info LIKE "INSERT INTO t1%";
--echo ## table contents befor UNLOCK ##
SELECT * FROM t1;
UNLOCK TABLES;
......
......@@ -123,7 +123,7 @@ connection default;
--echo ** Wait till con0 is blocked **
let $wait_condition=
SELECT COUNT(*) = 1 FROM information_schema.processlist
WHERE state = 'Table lock' AND info = '$my_select';
WHERE state = 'Waiting for table level lock' AND info = '$my_select';
--source include/wait_condition.inc
UNLOCK TABLES;
......@@ -219,7 +219,7 @@ connection default;
--echo ** Wait till con0 is blocked **
let $wait_condition=
SELECT COUNT(*) = 1 FROM information_schema.processlist
WHERE state = 'Table lock' AND info = '$my_select';
WHERE state = 'Waiting for table level lock' AND info = '$my_select';
--source include/wait_condition.inc
UNLOCK TABLES;
......
......@@ -60,8 +60,6 @@ INSERT INTO t1 VALUES(1, 'val1');
INSERT INTO t1 VALUES(2, 'val2');
INSERT INTO t1 VALUES(3, 'val3');
CREATE VIEW v1 AS SELECT * FROM t1;
#
# Clearing the query cache and setting up cache size
#
......@@ -101,7 +99,7 @@ SELECT * FROM t1;
SHOW STATUS LIKE 'Qcache_queries_in_cache';
--echo 1 Expected
LOCK TABLE v1 WRITE;
LOCK TABLE t1 WRITE;
UNLOCK TABLES;
......@@ -129,7 +127,7 @@ SELECT * FROM t1;
--echo ** Connection con0 **
connection con0;
LOCK TABLE v1 WRITE;
LOCK TABLE t1 WRITE;
--echo ** Connection con1 **
connection con1;
......@@ -141,7 +139,8 @@ send SELECT * FROM t1;
connection con0;
--echo wait until table is locked
let $wait_condition= SELECT count(*) > 0 FROM information_schema.processlist WHERE state= 'Table lock';
let $wait_condition= SELECT count(*) > 0 FROM information_schema.processlist
WHERE state= 'Waiting for table metadata lock';
--source include/wait_condition.inc
UNLOCK TABLES;
......@@ -177,7 +176,7 @@ SELECT * FROM t1;
SHOW STATUS LIKE 'Qcache_queries_in_cache';
--echo 1 Expected
LOCK TABLE v1 WRITE;
LOCK TABLE t1 WRITE;
UNLOCK TABLES;
......@@ -201,7 +200,7 @@ SELECT * FROM t1;
--echo ** Connection con0 **
connection con0;
LOCK TABLE v1 WRITE;
LOCK TABLE t1 WRITE;
--echo ** Connection con1 **
connection con1;
......@@ -283,7 +282,6 @@ disconnect con0;
disconnect con1;
DROP TABLE t1;
DROP VIEW v1;
--enable_ps_protocol
......@@ -86,7 +86,9 @@ delimiter ;|
--echo ** Connection con0 **
connection con0;
let $wait_condition = SELECT COUNT(*) > 0 FROM information_schema.processlist WHERE state='Table lock' AND info LIKE 'UPDATE t1 SET a = CONCAT(a,"-updated")';
let $wait_condition = SELECT COUNT(*) > 0 FROM information_schema.processlist
WHERE state='Waiting for table level lock' AND
info LIKE 'UPDATE t1 SET a = CONCAT(a,"-updated")';
--source include/wait_condition.inc
--echo ** Asynchronous Execution **
......@@ -102,7 +104,8 @@ delimiter ;|
--echo ** Connection default **
connection default;
let $wait_condition= SELECT count(*) = 2 FROM information_schema.processlist WHERE state LIKE 'Table lock';
let $wait_condition= SELECT count(*) = 2 FROM information_schema.processlist
WHERE state LIKE 'Waiting for table level lock';
--source include/wait_condition.inc
UNLOCK TABLES;
......@@ -157,7 +160,9 @@ delimiter ;|
--echo ** Connection con0 **
connection con0;
let $wait_condition = SELECT COUNT(*) > 0 FROM information_schema.processlist WHERE state='Table lock' AND info LIKE 'UPDATE t1 SET a = CONCAT(a,"-updated")';
let $wait_condition = SELECT COUNT(*) > 0 FROM information_schema.processlist
WHERE state='Waiting for table level lock' AND
info LIKE 'UPDATE t1 SET a = CONCAT(a,"-updated")';
--source include/wait_condition.inc
--echo ** Asynchronous Execution **
......@@ -173,7 +178,8 @@ delimiter ;|
--echo ** Connection default **
connection default;
let $wait_condition= SELECT count(*) = 2 FROM information_schema.processlist WHERE state LIKE 'Table lock';
let $wait_condition= SELECT count(*) = 2 FROM information_schema.processlist
WHERE state LIKE 'Waiting for table level lock';
--source include/wait_condition.inc
UNLOCK TABLES;
......
......@@ -307,7 +307,7 @@ connection update;
connection default;
let $wait_condition=
select count(*) = 1 from information_schema.processlist
where command = "Delayed insert" and state = "Table lock";
where command = "Delayed insert" and state = "Waiting for table level lock";
--source include/wait_condition.inc
connect (select,localhost,root,,);
--echo connection: select
......
......@@ -1470,7 +1470,8 @@ connection con3726_2;
connection default;
let $wait_condition=
select count(*) = 1 from information_schema.processlist
where state = "Waiting for table" and info like "rename table t2 to t3";
where state = "Waiting for table metadata lock" and
info like "rename table t2 to t3";
--source include/wait_condition.inc
--echo # These statements should not be blocked by pending lock requests
select table_name, column_name, data_type from information_schema.columns
......
......@@ -42,7 +42,7 @@ let $wait_condition=
let $wait_condition=
SELECT COUNT(*) = 1 FROM information_schema.processlist
WHERE info = "DROP TABLE t1" and
state = "Waiting for table";
state = "Waiting for table metadata lock";
--source include/wait_condition.inc
--echo # Connection 1 is now holding the lock.
--echo # Issuing insert from connection 1 while connection 2&3
......@@ -97,7 +97,8 @@ connection default;
--echo # connection holds SW metadata lock on table to be altered.
let $wait_condition=
select count(*) = 1 from information_schema.processlist
where state = "Waiting for table" and info = "alter table t1 add column c4 int";
where state = "Waiting for table metadata lock" and
info = "alter table t1 add column c4 int";
--source include/wait_condition.inc
--echo # The below statement should succeed. It should not
......@@ -196,7 +197,7 @@ connection default;
--echo # Connection con1
connection con1;
let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist
WHERE state='Waiting for table' AND info='OPTIMIZE TABLE t1';
WHERE state='Waiting for table metadata lock' AND info='OPTIMIZE TABLE t1';
--source include/wait_condition.inc
SELECT * FROM t1;
COMMIT;
......@@ -241,7 +242,7 @@ connection con2;
--echo # Waiting for 'SELECT * FROM v1' to sync in.
let $wait_condition=
SELECT COUNT(*) = 1 FROM information_schema.processlist
WHERE state = "Waiting for table" AND info = "SELECT * FROM v1";
WHERE state = "Waiting for table metadata lock" AND info = "SELECT * FROM v1";
--source include/wait_condition.inc
# This should block due to v1 being locked.
--echo # Sending:
......@@ -252,7 +253,8 @@ connection con3;
--echo # Waiting for 'ALTER VIEW v1 AS SELECT 2 FROM t2' to sync in.
let $wait_condition=
SELECT COUNT(*) = 1 FROM information_schema.processlist
WHERE state = "Waiting for table" AND info = "ALTER VIEW v1 AS SELECT 2 FROM t2";
WHERE state = "Waiting for table metadata lock" AND
info = "ALTER VIEW v1 AS SELECT 2 FROM t2";
--source include/wait_condition.inc
# Unlock t1 allowing SELECT * FROM v1 to proceed.
UNLOCK TABLES;
......
......@@ -799,8 +799,9 @@ connection default;
--echo # table as it acquires LOCK_S locks on rows of old version, which
--echo # are compatible with locks acquired by connection 'con1'.
let $wait_condition=
select count(*) = 1 from information_schema.processlist where state =
"Waiting for table" and info = "alter table t1 add column j int";
select count(*) = 1 from information_schema.processlist
where state = "Waiting for table metadata lock" and
info = "alter table t1 add column j int";
--source include/wait_condition.inc
--echo # The below statement will deadlock because it will try to acquire
......@@ -844,7 +845,8 @@ connection default;
--echo # Wait until ALTER is blocked because of active SR lock.
let $wait_condition=
select count(*) = 1 from information_schema.processlist
where state = "Waiting for table" and info = "alter table t1 rebuild partition p0";
where state = "Waiting for table metadata lock" and
info = "alter table t1 rebuild partition p0";
--source include/wait_condition.inc
--echo # The below statement should succeed as transaction
......
......@@ -174,7 +174,7 @@ connection default;
# we must wait till the insert opens and locks the table
let $wait_condition=
select count(*) = 1 from information_schema.processlist
where state = "Table lock" and id = $ID;
where state = "Waiting for table level lock" and id = $ID;
--source include/wait_condition.inc
connect (select,localhost,root,,);
--echo connection: select
......
......@@ -357,7 +357,8 @@ let $ID= `select connection_id()`;
connection default;
let $wait_condition=
select count(*) = 1 from information_schema.processlist
where state = "Waiting for table" and info = "rename table t1 to t2";
where state = "Waiting for table metadata lock" and
info = "rename table t1 to t2";
--source include/wait_condition.inc
--replace_result $ID ID
eval kill query $ID;
......@@ -372,7 +373,7 @@ connection ddl;
connection default;
let $wait_condition=
select count(*) = 1 from information_schema.processlist
where state = "Waiting for table" and
where state = "Waiting for table metadata lock" and
info = "drop table t1";
--source include/wait_condition.inc
--replace_result $ID ID
......@@ -388,7 +389,7 @@ connection ddl;
connection default;
let $wait_condition=
select count(*) = 1 from information_schema.processlist
where state = "Waiting for table" and
where state = "Waiting for table metadata lock" and
info = "create trigger t1_bi before insert on t1 for each row set @a:=1";
--source include/wait_condition.inc
--replace_result $ID ID
......@@ -407,7 +408,7 @@ connection ddl;
connection default;
let $wait_condition=
select count(*) = 1 from information_schema.processlist
where state = "Waiting for table" and
where state = "Waiting for table metadata lock" and
info = "alter table t1 add column j int";
--source include/wait_condition.inc
--replace_result $ID ID
......@@ -423,7 +424,7 @@ connection ddl;
connection default;
let $wait_condition=
select count(*) = 1 from information_schema.processlist
where state = "Waiting for table" and
where state = "Waiting for table metadata lock" and
info = "alter table t1 rename to t2";
--source include/wait_condition.inc
--replace_result $ID ID
......@@ -437,7 +438,7 @@ connection ddl;
connection default;
let $wait_condition=
select count(*) = 1 from information_schema.processlist
where state = "Waiting for table" and
where state = "Waiting for table metadata lock" and
info = "alter table t1 disable keys";
--source include/wait_condition.inc
--replace_result $ID ID
......@@ -452,7 +453,7 @@ connection ddl;
connection default;
let $wait_condition=
select count(*) = 1 from information_schema.processlist
where state = "Waiting for table" and
where state = "Waiting for table metadata lock" and
info = "alter table t1 alter column i set default 100";
--source include/wait_condition.inc
--replace_result $ID ID
......@@ -474,7 +475,7 @@ connection ddl;
connection default;
let $wait_condition=
select count(*) = 1 from information_schema.processlist
where state = "Waiting for table" and
where state = "Waiting for table metadata lock" and
info = "alter table t2 alter column i set default 100";
--source include/wait_condition.inc
--replace_result $ID ID
......@@ -499,7 +500,7 @@ connection ddl;
connection dml;
let $wait_condition=
select count(*) = 1 from information_schema.processlist
where state = "Waiting for table" and
where state = "Waiting for table metadata lock" and
info = "rename tables t1 to t3, t2 to t1";
--source include/wait_condition.inc
let $ID2= `select connection_id()`;
......@@ -508,7 +509,7 @@ let $ID2= `select connection_id()`;
connection default;
let $wait_condition=
select count(*) = 1 from information_schema.processlist
where state = "Waiting for table" and
where state = "Waiting for table metadata lock" and
info = "insert into t2 values (1)";
--source include/wait_condition.inc
--replace_result $ID2 ID2
......@@ -544,7 +545,7 @@ let $wait_condition=
connection default;
let $wait_condition=
select count(*) = 1 from information_schema.processlist
where state = "Waiting for table" and
where state = "Waiting for table flush" and
info = "select * from t1";
--source include/wait_condition.inc
--replace_result $ID2 ID2
......
This diff is collapsed.
......@@ -898,7 +898,7 @@ set debug_sync= 'now WAIT_FOR parked';
connection default;
--echo # Wait until this LOCK TABLES statement starts waiting for table lock.
let $wait_condition= select count(*)= 1 from information_schema.processlist
where state= 'Table lock' and
where state= 'Waiting for table level lock' and
info='lock table v1 write';
--source include/wait_condition.inc
--echo # Allow SELECT ... FOR UPDATE to resume.
......@@ -972,7 +972,7 @@ connection default;
connection con2;
let $wait_condition=
SELECT COUNT(*) = 1 FROM information_schema.processlist
WHERE state = "Waiting for table"
WHERE state = "Waiting for table metadata lock"
AND info = "ALTER TABLE t1 ADD COLUMN j INT";
--source include/wait_condition.inc
......
This diff is collapsed.
......@@ -51,7 +51,7 @@ connection default;
#--sleep 8
#SELECT ID,STATE,INFO FROM INFORMATION_SCHEMA.PROCESSLIST;
let $wait_condition= SELECT 1 FROM INFORMATION_SCHEMA.PROCESSLIST
WHERE ID = $con1_id AND STATE = 'Waiting for table';
WHERE ID = $con1_id AND STATE = 'Waiting for table metadata lock';
--source include/wait_condition.inc
#SELECT NOW();
--echo # Kick INSERT out of thr_multi_lock().
......@@ -61,7 +61,7 @@ FLUSH TABLES;
#--sleep 8
#SELECT ID,STATE,INFO FROM INFORMATION_SCHEMA.PROCESSLIST;
let $wait_condition= SELECT 1 FROM INFORMATION_SCHEMA.PROCESSLIST
WHERE ID = $con1_id AND STATE = 'Waiting for table';
WHERE ID = $con1_id AND STATE = 'Waiting for table metadata lock';
--source include/wait_condition.inc
#SELECT NOW();
--echo # Unlock and close table and wait for con1 to close too.
......
......@@ -497,7 +497,7 @@ connection updater;
# Wait till "alter table t1 ..." of session changer is in work.
# = There is one session waiting.
let $wait_condition= select count(*)= 1 from information_schema.processlist
where state= 'Waiting for table';
where state= 'Waiting for table metadata lock';
--source include/wait_condition.inc
send update t1, v1 set t1.b=t1.a+t1.b+v1.b where t1.a=v1.a;
......@@ -508,7 +508,7 @@ connection locker;
# are in work.
# = There are two session waiting.
let $wait_condition= select count(*)= 2 from information_schema.processlist
where state= 'Waiting for table';
where state= 'Waiting for table metadata lock';
--source include/wait_condition.inc
unlock tables;
......
......@@ -498,12 +498,20 @@ drop table t1,t2,t3,t4;
set query_cache_wlock_invalidate=1;
create table t1 (a int not null);
create table t2 (a int not null);
create view v1 as select * from t1;
select * from t1;
select * from t2;
show status like "Qcache_queries_in_cache";
lock table t1 write, t2 read;
show status like "Qcache_queries_in_cache";
unlock table;
select * from t1;
# Implicit locking of t1 does not invalidate QC
show status like "Qcache_queries_in_cache";
lock table v1 write;
show status like "Qcache_queries_in_cache";
unlock table;
drop view v1;
drop table t1,t2;
set query_cache_wlock_invalidate=default;
......
......@@ -58,18 +58,18 @@ connection user3;
# Typical information_schema.processlist content after sufficient sleep time
# ID USER COMMAND TIME STATE INFO
# ....
# 2 root Query 5 Table lock SELECT *, (SELECT COUNT(*) FROM t2) FROM t1
# 2 root Query 5 Waiting for table level lock SELECT *, (SELECT COUNT(*) FROM t2) FROM t1
# ....
# XXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
# The values marked with 'X' must be reached.
--echo # Poll till the select of connection user1 is blocked by the write lock on t1.
let $wait_condition= SELECT COUNT(*) = 1 FROM information_schema.processlist
WHERE state = 'Table lock'
WHERE state = 'Waiting for table level lock'
AND info = '$select_for_qc';
--source include/wait_condition.inc
eval
SELECT user,command,state,info FROM information_schema.processlist
WHERE state = 'Table lock'
WHERE state = 'Waiting for table level lock'
AND info = '$select_for_qc';
INSERT INTO t1 VALUES (4);
......
......@@ -45,7 +45,7 @@ connection con2;
--echo # Connection default
connection default;
let $wait_condition= SELECT COUNT(*)= 1 FROM information_schema.processlist
WHERE state= 'Waiting for table'
WHERE state= 'Waiting for table metadata lock'
AND info='DROP SCHEMA schema1';
--source include/wait_condition.inc
ALTER SCHEMA schema2 DEFAULT CHARACTER SET utf8;
......@@ -84,7 +84,7 @@ connection con2;
--echo # Connection default
connection default;
let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist
WHERE state='Waiting for table' and info='DROP SCHEMA schema1';
WHERE state='Waiting for schema metadata lock' and info='DROP SCHEMA schema1';
--source include/wait_condition.inc
--echo # CREATE SCHEMA used to give a deadlock.
......@@ -124,7 +124,7 @@ connection default;
--echo # Connection con2
connect (con2, localhost, root);
let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist
WHERE state='Waiting for table' AND info='DROP DATABASE db1';
WHERE state='Waiting for table metadata lock' AND info='DROP DATABASE db1';
--source include/wait_condition.inc
--echo # Connection con1
......@@ -172,7 +172,7 @@ connection con2;
--echo # Connection 3
connection con3;
let $wait_condition=SELECT COUNT(*)=1 FROM information_schema.processlist
WHERE state='Waiting for table' and info='DROP DATABASE db1';
WHERE state='Waiting for table metadata lock' and info='DROP DATABASE db1';
--source include/wait_condition.inc
--echo # But it should still be possible to CREATE/ALTER/DROP other databases.
CREATE DATABASE db2;
......
This diff is collapsed.
......@@ -322,7 +322,7 @@ set session low_priority_updates=on;
connection rl_wait;
let $wait_condition=
select count(*) = 1 from information_schema.processlist
where state = "Table lock" and
where state = "Waiting for table level lock" and
info = "update t1 set value='updated' where value='old'";
--source include/wait_condition.inc
......
......@@ -87,7 +87,7 @@ SET DEBUG_SYNC= 'now WAIT_FOR locked';
--echo # Connection con3
connection con3;
let $wait_condition= SELECT COUNT(*)= 1 FROM information_schema.processlist
WHERE state= 'Waiting for table'
WHERE state= 'Waiting for stored function metadata lock'
AND info='SHOW OPEN TABLES WHERE f1()=0';
--source include/wait_condition.inc
--echo # Check that the IS query is blocked before releasing the x-lock
......
......@@ -58,7 +58,8 @@ let $ID= `select connection_id()`;
connection con2;
--echo # Switched to connection: con2
# wait for the other query to start executing
let $wait_condition= select 1 from INFORMATION_SCHEMA.PROCESSLIST where ID = $ID and STATE = "Table lock";
let $wait_condition= select 1 from INFORMATION_SCHEMA.PROCESSLIST
where ID = $ID and STATE = "Waiting for table level lock";
--source include/wait_condition.inc
unlock tables;
......
......@@ -896,7 +896,7 @@ connection default;
--echo connection: default
let $wait_condition=
select count(*) = 1 from information_schema.processlist
where state = "Waiting for table";
where state = "Waiting for global metadata lock";
--source include/wait_condition.inc
create trigger t1_bi before insert on t1 for each row begin end;
unlock tables;
......
......@@ -4074,7 +4074,8 @@ connection default;
connection con2;
let $wait_condition=
SELECT COUNT(*) = 1 from information_schema.processlist
WHERE state = "Table lock" AND info = "INSERT INTO t1 SELECT * FROM v1";
WHERE state = "Waiting for table level lock" AND
info = "INSERT INTO t1 SELECT * FROM v1";
--source include/wait_condition.inc
--echo # ... then try to drop the view. This should block.
--echo # Sending:
......@@ -4084,7 +4085,7 @@ let $wait_condition=
connection con3;
let $wait_condition=
SELECT COUNT(*) = 1 from information_schema.processlist
WHERE state = "Waiting for table" AND info = "DROP VIEW v1";
WHERE state = "Waiting for table metadata lock" AND info = "DROP VIEW v1";
--source include/wait_condition.inc
--echo # Now allow CALL p1() to complete
UNLOCK TABLES;
......
......@@ -428,7 +428,7 @@ wait_for_lock(struct st_lock_list *wait, THR_LOCK_DATA *data,
thread_var->current_cond= cond;
data->cond= cond;
old_proc_info= proc_info_hook(NULL, "Table lock",
old_proc_info= proc_info_hook(NULL, "Waiting for table level lock",
__func__, __FILE__, __LINE__);
set_timespec(wait_timeout, lock_wait_timeout);
......
......@@ -71,6 +71,21 @@ static void init_mdl_psi_keys(void)
void notify_shared_lock(THD *thd, MDL_ticket *conflicting_ticket);
/**
Thread state names to be used in case when we have to wait on resource
belonging to certain namespace.
*/
const char *MDL_key::m_namespace_to_wait_state_name[NAMESPACE_END]=
{
"Waiting for global metadata lock",
"Waiting for schema metadata lock",
"Waiting for table metadata lock",
"Waiting for stored function metadata lock",
"Waiting for stored procedure metadata lock",
NULL
};
static bool mdl_initialized= 0;
......@@ -946,17 +961,18 @@ void MDL_wait::reset_status()
Wait for the status to be assigned to this wait slot.
@param abs_timeout Absolute time after which waiting should stop.
@param set_status_on_tiemout TRUE - If in case of timeout waiting
@param set_status_on_timeout TRUE - If in case of timeout waiting
context should close the wait slot by
sending TIMEOUT to itself.
FALSE - Otherwise.
@param wait_state_name Thread state name to be set for duration of wait.
@returns Signal posted.
*/
MDL_wait::enum_wait_status
MDL_wait::timed_wait(THD *thd, struct timespec *abs_timeout,
bool set_status_on_timeout)
bool set_status_on_timeout, const char *wait_state_name)
{
const char *old_msg;
enum_wait_status result;
......@@ -965,7 +981,7 @@ MDL_wait::timed_wait(THD *thd, struct timespec *abs_timeout,
mysql_mutex_lock(&m_LOCK_wait_status);
old_msg= thd_enter_cond(thd, &m_COND_wait_status, &m_LOCK_wait_status,
"Waiting for table");
wait_state_name);
while (!m_wait_status && !thd_killed(thd) &&
wait_result != ETIMEDOUT && wait_result != ETIME)
......@@ -1746,7 +1762,8 @@ MDL_context::acquire_lock(MDL_request *mdl_request, ulong lock_wait_timeout)
while (cmp_timespec(abs_shortwait, abs_timeout) <= 0)
{
/* abs_timeout is far away. Wait a short while and notify locks. */
wait_status= m_wait.timed_wait(m_thd, &abs_shortwait, FALSE);
wait_status= m_wait.timed_wait(m_thd, &abs_shortwait, FALSE,
mdl_request->key.get_wait_state_name());
if (wait_status != MDL_wait::EMPTY)
break;
......@@ -1757,10 +1774,12 @@ MDL_context::acquire_lock(MDL_request *mdl_request, ulong lock_wait_timeout)
set_timespec(abs_shortwait, 1);
}
if (wait_status == MDL_wait::EMPTY)
wait_status= m_wait.timed_wait(m_thd, &abs_timeout, TRUE);
wait_status= m_wait.timed_wait(m_thd, &abs_timeout, TRUE,
mdl_request->key.get_wait_state_name());
}
else
wait_status= m_wait.timed_wait(m_thd, &abs_timeout, TRUE);
wait_status= m_wait.timed_wait(m_thd, &abs_timeout, TRUE,
mdl_request->key.get_wait_state_name());
done_waiting_for();
......
......@@ -184,7 +184,9 @@ class MDL_key
TABLE,
FUNCTION,
PROCEDURE,
TRIGGER };
TRIGGER,
/* This should be the last ! */
NAMESPACE_END };
const uchar *ptr() const { return (uchar*) m_ptr; }
uint length() const { return m_length; }
......@@ -251,10 +253,20 @@ class MDL_key
}
MDL_key() {} /* To use when part of MDL_request. */
/**
Get thread state name to be used in case when we have to
wait on resource identified by key.
*/
const char * get_wait_state_name() const
{
return m_namespace_to_wait_state_name[(int)mdl_namespace()];
}
private:
uint16 m_length;
uint16 m_db_name_length;
char m_ptr[MAX_MDLKEY_LENGTH];
static const char * m_namespace_to_wait_state_name[NAMESPACE_END];
private:
MDL_key(const MDL_key &); /* not implemented */
MDL_key &operator=(const MDL_key &); /* not implemented */
......@@ -462,7 +474,7 @@ class MDL_wait
enum_wait_status get_status();
void reset_status();
enum_wait_status timed_wait(THD *thd, struct timespec *abs_timeout,
bool signal_timeout);
bool signal_timeout, const char *wait_state_name);
private:
/**
Condvar which is used for waiting until this context's pending
......
......@@ -8772,7 +8772,8 @@ tdc_wait_for_old_versions(THD *thd, MDL_request_list *mdl_requests,
my_error(ER_LOCK_WAIT_TIMEOUT, MYF(0));
break;
}
old_msg= thd->enter_cond(&COND_refresh, &LOCK_open, "Waiting for table");
old_msg= thd->enter_cond(&COND_refresh, &LOCK_open,
"Waiting for table flush");
wait_result= mysql_cond_timedwait(&COND_refresh, &LOCK_open, &abstime);
/* LOCK_open mutex is unlocked by THD::exit_cond() as side-effect. */
thd->exit_cond(old_msg);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment