mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Bug#40536: SELECT is blocked by INSERT DELAYED waiting on
upgrading lock, even with low_priority_updates The problem is that there is no mechanism to control whether a delayed insert takes a high or low priority lock on a table. The solution is to modify the delayed insert thread ("handler") to take into account the global value of low_priority_updates when taking table locks. The value of low_priority_updates is retrieved when the insert delayed thread is created and will remain the same for the duration of the thread. include/thr_lock.h: Update prototype. mysql-test/r/delayed.result: Add test case result for Bug#40536 mysql-test/t/delayed.test: Add test case for Bug#40536 mysys/thr_lock.c: Add function parameter which specifies the write lock type. sql/sql_insert.cc: Take a low priority write lock if global value of low_priority_updates was ON when the thread was created.
This commit is contained in:
@ -284,4 +284,30 @@ ERROR 22007: Incorrect date value: '0000-00-00' for column 'f1' at row 1
|
||||
INSERT DELAYED INTO t2 VALUES (0,'2007-00-00');
|
||||
ERROR 22007: Incorrect date value: '2007-00-00' for column 'f1' at row 1
|
||||
DROP TABLE t1,t2;
|
||||
set @old_delayed_updates = @@global.low_priority_updates;
|
||||
set global low_priority_updates = 1;
|
||||
select @@global.low_priority_updates;
|
||||
@@global.low_priority_updates
|
||||
1
|
||||
drop table if exists t1;
|
||||
create table t1 (a int, b int);
|
||||
insert into t1 values (1,1);
|
||||
lock table t1 read;
|
||||
connection: update
|
||||
insert delayed into t1 values (2,2);;
|
||||
connection: select
|
||||
select * from t1;
|
||||
a b
|
||||
1 1
|
||||
connection: default
|
||||
select * from t1;
|
||||
a b
|
||||
1 1
|
||||
unlock tables;
|
||||
select * from t1;
|
||||
a b
|
||||
1 1
|
||||
2 2
|
||||
drop table t1;
|
||||
set global low_priority_updates = @old_delayed_updates;
|
||||
End of 5.1 tests
|
||||
|
@ -285,4 +285,47 @@ INSERT DELAYED INTO t2 VALUES (0,'0000-00-00');
|
||||
INSERT DELAYED INTO t2 VALUES (0,'2007-00-00');
|
||||
DROP TABLE t1,t2;
|
||||
|
||||
#
|
||||
# Bug#40536: SELECT is blocked by INSERT DELAYED waiting on upgrading lock,
|
||||
# even with low_priority_updates
|
||||
#
|
||||
|
||||
set @old_delayed_updates = @@global.low_priority_updates;
|
||||
set global low_priority_updates = 1;
|
||||
select @@global.low_priority_updates;
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
--enable_warnings
|
||||
create table t1 (a int, b int);
|
||||
insert into t1 values (1,1);
|
||||
lock table t1 read;
|
||||
connect (update,localhost,root,,);
|
||||
connection update;
|
||||
--echo connection: update
|
||||
--send insert delayed into t1 values (2,2);
|
||||
connection default;
|
||||
let $wait_condition=
|
||||
select count(*) = 1 from information_schema.processlist
|
||||
where command = "Delayed insert" and state = "upgrading lock";
|
||||
--source include/wait_condition.inc
|
||||
connect (select,localhost,root,,);
|
||||
--echo connection: select
|
||||
select * from t1;
|
||||
connection default;
|
||||
--echo connection: default
|
||||
select * from t1;
|
||||
connection default;
|
||||
disconnect update;
|
||||
disconnect select;
|
||||
unlock tables;
|
||||
let $wait_condition=
|
||||
select count(*) = 1 from information_schema.processlist
|
||||
where command = "Delayed insert" and state = "Waiting for INSERT";
|
||||
--source include/wait_condition.inc
|
||||
select * from t1;
|
||||
drop table t1;
|
||||
|
||||
set global low_priority_updates = @old_delayed_updates;
|
||||
|
||||
--echo End of 5.1 tests
|
||||
|
Reference in New Issue
Block a user