mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
Backport of:
------------------------------------------------------------ revno: 3035.4.1 committer: Davi Arnaut <Davi.Arnaut@Sun.COM> branch nick: 39897-6.0 timestamp: Thu 2009-01-15 12:17:57 -0200 message: Bug#39897: lock_multi fails in pushbuild: timeout waiting for processlist The problem is that relying on the "Table lock" thread state in its current position to detect that a thread is waiting on a lock is race prone. The "Table lock" state change happens before the thread actually tries to grab a lock on a table. The solution is to move the "Table lock" state so that its set only when a thread is actually going to wait for a lock. The state change happens after the thread fails to grab the lock (because it is owned by other thread) and proceeds to wait on a condition. This is considered part of work related to WL#4284 "Transactional DDL locking" Warning: this patch contains an incompatible change. When waiting on a lock in thr_lock.c, the server used to display "Locked" processlist state. After this patch, the state is "Table lock". The new state was actually intended to be display since year 2002, when Monty added it. But up until removal of thd->locked boolean member, this state was ignored by SHOW PROCESSLIST code.
This commit is contained in:
@ -22,7 +22,7 @@ connection reader;
|
||||
# Sleep a bit till the update of connection writer is in work and hangs
|
||||
let $wait_condition=
|
||||
select count(*) = 1 from information_schema.processlist
|
||||
where state = "Locked" and info = "update low_priority t1 set n = 4";
|
||||
where state = "Table lock" and info = "update low_priority t1 set n = 4";
|
||||
--source include/wait_condition.inc
|
||||
send
|
||||
select n from t1;
|
||||
@ -30,7 +30,7 @@ connection locker;
|
||||
# Sleep a bit till the select of connection reader is in work and hangs
|
||||
let $wait_condition=
|
||||
select count(*) = 1 from information_schema.processlist
|
||||
where state = "Locked" and info = "select n from t1";
|
||||
where state = "Table lock" and info = "select n from t1";
|
||||
--source include/wait_condition.inc
|
||||
unlock tables;
|
||||
connection writer;
|
||||
@ -50,7 +50,7 @@ connection reader;
|
||||
# Sleep a bit till the update of connection writer is in work and hangs
|
||||
let $wait_condition=
|
||||
select count(*) = 1 from information_schema.processlist
|
||||
where state = "Locked" and info = "update low_priority t1 set n = 4";
|
||||
where state = "Table lock" and info = "update low_priority t1 set n = 4";
|
||||
--source include/wait_condition.inc
|
||||
select n from t1;
|
||||
connection locker;
|
||||
@ -95,7 +95,7 @@ insert t1 select * from t2;
|
||||
connection locker;
|
||||
let $wait_condition=
|
||||
select count(*) = 1 from information_schema.processlist
|
||||
where state = "Locked" and info = "insert t1 select * from t2";
|
||||
where state = "Table lock" and info = "insert t1 select * from t2";
|
||||
--source include/wait_condition.inc
|
||||
drop table t2;
|
||||
connection reader;
|
||||
@ -119,7 +119,7 @@ connection locker;
|
||||
# Sleep a bit till the insert of connection reader is in work and hangs
|
||||
let $wait_condition=
|
||||
select count(*) = 1 from information_schema.processlist
|
||||
where state = "Locked" and info = "insert t1 select * from t2";
|
||||
where state = "Table lock" and info = "insert t1 select * from t2";
|
||||
--source include/wait_condition.inc
|
||||
drop table t2;
|
||||
connection reader;
|
||||
@ -163,8 +163,8 @@ SELECT user.Select_priv FROM user, db WHERE user.user = db.user LIMIT 1;
|
||||
connection locker;
|
||||
# Sleep a bit till the select of connection reader is in work and hangs
|
||||
let $wait_condition=
|
||||
select count(*) = 1 from information_schema.processlist
|
||||
where state = "Locked" and info =
|
||||
SELECT COUNT(*) = 1 FROM information_schema.processlist
|
||||
WHERE state = "Table lock" AND info =
|
||||
"SELECT user.Select_priv FROM user, db WHERE user.user = db.user LIMIT 1";
|
||||
--source include/wait_condition.inc
|
||||
# Make test case independent from earlier grants.
|
||||
@ -298,7 +298,7 @@ connection reader;
|
||||
# Wait till connection writer is blocked
|
||||
let $wait_condition=
|
||||
select count(*) = 1 from information_schema.processlist
|
||||
where state = "Locked" and info = "alter table t1 auto_increment=0";
|
||||
where state = "Table lock" and info = "alter table t1 auto_increment=0";
|
||||
--source include/wait_condition.inc
|
||||
send
|
||||
alter table t1 auto_increment=0;
|
||||
@ -306,7 +306,7 @@ connection locker;
|
||||
# Wait till connection reader is blocked
|
||||
let $wait_condition=
|
||||
select count(*) = 2 from information_schema.processlist
|
||||
where state = "Locked" and info = "alter table t1 auto_increment=0";
|
||||
where state = "Table lock" and info = "alter table t1 auto_increment=0";
|
||||
--source include/wait_condition.inc
|
||||
unlock tables;
|
||||
connection writer;
|
||||
@ -461,16 +461,16 @@ update t1 set i= 10;
|
||||
connection reader;
|
||||
let $wait_condition=
|
||||
select count(*) = 1 from information_schema.processlist
|
||||
where state = "Locked" and info = "update t1 set i= 10";
|
||||
where state = "Table lock" and info = "update t1 set i= 10";
|
||||
--source include/wait_condition.inc
|
||||
send
|
||||
select * from t1;
|
||||
connection default;
|
||||
let $wait_condition=
|
||||
select count(*) = 1 from information_schema.processlist
|
||||
where state = "Locked" and info = "select * from t1";
|
||||
where state = "Table lock" and info = "select * from t1";
|
||||
--source include/wait_condition.inc
|
||||
let $ID= `select id from information_schema.processlist where state = "Locked" and info = "update t1 set i= 10"`;
|
||||
let $ID= `select id from information_schema.processlist where state = "Table lock" and info = "update t1 set i= 10"`;
|
||||
--replace_result $ID ID
|
||||
eval kill query $ID;
|
||||
connection reader;
|
||||
@ -613,11 +613,11 @@ lock tables t1 read;
|
||||
let $tlwa= `show status like 'Table_locks_waited'`;
|
||||
connect (waiter,localhost,root,,);
|
||||
connection waiter;
|
||||
--send insert into t1 values(1);
|
||||
send insert into t1 values(1);
|
||||
connection default;
|
||||
let $wait_condition=
|
||||
select count(*) = 1 from information_schema.processlist
|
||||
where state = "Locked" and info = "insert into t1 values(1)";
|
||||
where state = "Table lock" and info = "insert into t1 values(1)";
|
||||
--source include/wait_condition.inc
|
||||
let $tlwb= `show status like 'Table_locks_waited'`;
|
||||
unlock tables;
|
||||
|
Reference in New Issue
Block a user