mirror of
https://github.com/MariaDB/server.git
synced 2025-12-21 11:01:08 +03:00
Make innodb_unsafe_binlog test case faster. Group all consistent read
test cases to a one test case and wait their lock timeout after all have been send to the server. Remove unnecessary option --loose_innodb_lock_wait_timeout.
This commit is contained in:
@@ -1 +1 @@
|
|||||||
--binlog_cache_size=32768 --innodb_lock_wait_timeout=1 --loose_innodb_lock_wait_timeout=1
|
--binlog_cache_size=32768 --innodb_lock_wait_timeout=1
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
--innodb_locks_unsafe_for_binlog=true --innodb_lock_wait_timeout=2 --loose_innodb_lock_wait_timeout=2
|
--innodb_locks_unsafe_for_binlog=true --innodb_lock_wait_timeout=1
|
||||||
@@ -48,55 +48,37 @@ commit;
|
|||||||
drop table t1;
|
drop table t1;
|
||||||
create table t1(a int not null, b int, primary key(a)) engine=innodb;
|
create table t1(a int not null, b int, primary key(a)) engine=innodb;
|
||||||
insert into t1 values (1,2),(5,3),(4,2);
|
insert into t1 values (1,2),(5,3),(4,2);
|
||||||
create table t2(a int not null, b int, primary key(a)) engine=innodb;
|
create table t2(d int not null, e int, primary key(d)) engine=innodb;
|
||||||
insert into t2 values (8,6),(12,1),(3,1);
|
insert into t2 values (8,6),(12,1),(3,1);
|
||||||
commit;
|
commit;
|
||||||
set autocommit = 0;
|
set autocommit = 0;
|
||||||
select * from t2 for update;
|
select * from t2 for update;
|
||||||
a b
|
d e
|
||||||
3 1
|
3 1
|
||||||
8 6
|
8 6
|
||||||
12 1
|
12 1
|
||||||
set autocommit = 0;
|
set autocommit = 0;
|
||||||
insert into t1 select * from t2;
|
insert into t1 select * from t2;
|
||||||
commit;
|
|
||||||
commit;
|
|
||||||
drop table t1, t2;
|
|
||||||
create table t1(a int not null, b int, primary key(a)) engine=innodb;
|
|
||||||
insert into t1 values (1,2),(5,3),(4,2);
|
|
||||||
create table t2(d int not null, e int, primary key(d)) engine=innodb;
|
|
||||||
insert into t2 values (1,6),(5,1),(4,1);
|
|
||||||
commit;
|
|
||||||
set autocommit = 0;
|
|
||||||
select * from t2 for update;
|
|
||||||
d e
|
|
||||||
1 6
|
|
||||||
4 1
|
|
||||||
5 1
|
|
||||||
set autocommit = 0;
|
|
||||||
update t1 set b = (select e from t2 where a = d);
|
update t1 set b = (select e from t2 where a = d);
|
||||||
commit;
|
create table t3(d int not null, e int, primary key(d)) engine=innodb
|
||||||
commit;
|
|
||||||
drop table t1, t2;
|
|
||||||
create table t2(a int not null, b int, primary key(a)) engine=innodb;
|
|
||||||
insert into t2 values (1,6),(5,1),(4,1);
|
|
||||||
commit;
|
|
||||||
set autocommit = 0;
|
|
||||||
select * from t2 for update;
|
|
||||||
a b
|
|
||||||
1 6
|
|
||||||
4 1
|
|
||||||
5 1
|
|
||||||
set autocommit = 0;
|
|
||||||
create table t1(a int not null, b int, primary key(a)) engine=innodb
|
|
||||||
select * from t2;
|
select * from t2;
|
||||||
commit;
|
commit;
|
||||||
commit;
|
commit;
|
||||||
drop table t1, t2;
|
drop table t1, t2, t3;
|
||||||
create table t1(a int not null, b int, primary key(a)) engine=innodb;
|
create table t1(a int not null, b int, primary key(a)) engine=innodb;
|
||||||
insert into t1 values (1,2),(5,3),(4,2);
|
insert into t1 values (1,2),(5,3),(4,2);
|
||||||
create table t2(a int not null, b int, primary key(a)) engine=innodb;
|
create table t2(a int not null, b int, primary key(a)) engine=innodb;
|
||||||
insert into t2 values (8,6),(12,1),(3,1);
|
insert into t2 values (8,6),(12,1),(3,1);
|
||||||
|
create table t3(d int not null, b int, primary key(d)) engine=innodb;
|
||||||
|
insert into t3 values (8,6),(12,1),(3,1);
|
||||||
|
create table t5(a int not null, b int, primary key(a)) engine=innodb;
|
||||||
|
insert into t5 values (1,2),(5,3),(4,2);
|
||||||
|
create table t6(d int not null, e int, primary key(d)) engine=innodb;
|
||||||
|
insert into t6 values (8,6),(12,1),(3,1);
|
||||||
|
create table t8(a int not null, b int, primary key(a)) engine=innodb;
|
||||||
|
insert into t8 values (1,2),(5,3),(4,2);
|
||||||
|
create table t9(d int not null, e int, primary key(d)) engine=innodb;
|
||||||
|
insert into t9 values (8,6),(12,1),(3,1);
|
||||||
commit;
|
commit;
|
||||||
set autocommit = 0;
|
set autocommit = 0;
|
||||||
select * from t2 for update;
|
select * from t2 for update;
|
||||||
@@ -107,140 +89,32 @@ a b
|
|||||||
set autocommit = 0;
|
set autocommit = 0;
|
||||||
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
|
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
|
||||||
insert into t1 select * from t2;
|
insert into t1 select * from t2;
|
||||||
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
|
|
||||||
commit;
|
|
||||||
commit;
|
|
||||||
drop table t1, t2;
|
|
||||||
create table t1(a int not null, b int, primary key(a)) engine=innodb;
|
|
||||||
insert into t1 values (1,2),(5,3),(4,2);
|
|
||||||
create table t2(d int not null, e int, primary key(d)) engine=innodb;
|
|
||||||
insert into t2 values (1,6),(5,1),(4,1);
|
|
||||||
commit;
|
|
||||||
set autocommit = 0;
|
|
||||||
select * from t2 for update;
|
|
||||||
d e
|
|
||||||
1 6
|
|
||||||
4 1
|
|
||||||
5 1
|
|
||||||
set autocommit = 0;
|
set autocommit = 0;
|
||||||
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
|
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
|
||||||
update t1 set b = (select e from t2 where a = d);
|
update t3 set b = (select b from t2 where a = d);
|
||||||
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
|
|
||||||
commit;
|
|
||||||
commit;
|
|
||||||
drop table t1, t2;
|
|
||||||
create table t2(a int not null, b int, primary key(a)) engine=innodb;
|
|
||||||
insert into t2 values (1,6),(5,1),(4,1);
|
|
||||||
commit;
|
|
||||||
set autocommit = 0;
|
|
||||||
select * from t2 for update;
|
|
||||||
a b
|
|
||||||
1 6
|
|
||||||
4 1
|
|
||||||
5 1
|
|
||||||
set autocommit = 0;
|
set autocommit = 0;
|
||||||
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
|
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
|
||||||
create table t1(a int not null, b int, primary key(a)) engine=innodb
|
create table t4(a int not null, b int, primary key(a)) engine=innodb select * from t2;
|
||||||
select * from t2;
|
set autocommit = 0;
|
||||||
|
insert into t5 (select * from t2 lock in share mode);
|
||||||
|
set autocommit = 0;
|
||||||
|
update t6 set e = (select b from t2 where a = d lock in share mode);
|
||||||
|
set autocommit = 0;
|
||||||
|
create table t7(a int not null, b int, primary key(a)) engine=innodb select * from t2 lock in share mode;
|
||||||
|
set autocommit = 0;
|
||||||
|
insert into t8 (select * from t2 for update);
|
||||||
|
set autocommit = 0;
|
||||||
|
update t9 set e = (select b from t2 where a = d for update);
|
||||||
|
set autocommit = 0;
|
||||||
|
create table t10(a int not null, b int, primary key(a)) engine=innodb select * from t2 for update;
|
||||||
|
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
|
||||||
|
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
|
||||||
|
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
|
||||||
|
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
|
||||||
|
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
|
||||||
|
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
|
||||||
|
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
|
||||||
|
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
|
||||||
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
|
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
|
||||||
commit;
|
commit;
|
||||||
commit;
|
drop table t1, t2, t3, t5, t6, t8, t9;
|
||||||
drop table t2;
|
|
||||||
create table t1(a int not null, b int, primary key(a)) engine=innodb;
|
|
||||||
insert into t1 values (1,2),(5,3),(4,2);
|
|
||||||
create table t2(a int not null, b int, primary key(a)) engine=innodb;
|
|
||||||
insert into t2 values (8,6),(12,1),(3,1);
|
|
||||||
commit;
|
|
||||||
set autocommit = 0;
|
|
||||||
select * from t2 for update;
|
|
||||||
a b
|
|
||||||
3 1
|
|
||||||
8 6
|
|
||||||
12 1
|
|
||||||
set autocommit = 0;
|
|
||||||
insert into t1 select * from t2 lock in share mode;
|
|
||||||
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
|
|
||||||
commit;
|
|
||||||
commit;
|
|
||||||
drop table t1, t2;
|
|
||||||
create table t1(a int not null, b int, primary key(a)) engine=innodb;
|
|
||||||
insert into t1 values (1,2),(5,3),(4,2);
|
|
||||||
create table t2(d int not null, e int, primary key(d)) engine=innodb;
|
|
||||||
insert into t2 values (1,6),(5,1),(4,1);
|
|
||||||
commit;
|
|
||||||
set autocommit = 0;
|
|
||||||
select * from t2 for update;
|
|
||||||
d e
|
|
||||||
1 6
|
|
||||||
4 1
|
|
||||||
5 1
|
|
||||||
set autocommit = 0;
|
|
||||||
update t1 set b = (select e from t2 where a = d lock in share mode);
|
|
||||||
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
|
|
||||||
commit;
|
|
||||||
commit;
|
|
||||||
drop table t1, t2;
|
|
||||||
create table t2(a int not null, b int, primary key(a)) engine=innodb;
|
|
||||||
insert into t2 values (1,6),(5,1),(4,1);
|
|
||||||
commit;
|
|
||||||
set autocommit = 0;
|
|
||||||
select * from t2 for update;
|
|
||||||
a b
|
|
||||||
1 6
|
|
||||||
4 1
|
|
||||||
5 1
|
|
||||||
set autocommit = 0;
|
|
||||||
create table t1(a int not null, b int, primary key(a)) engine=innodb select * from t2 lock in share mode;
|
|
||||||
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
|
|
||||||
commit;
|
|
||||||
commit;
|
|
||||||
drop table t2;
|
|
||||||
create table t1(a int not null, b int, primary key(a)) engine=innodb;
|
|
||||||
insert into t1 values (1,2),(5,3),(4,2);
|
|
||||||
create table t2(a int not null, b int, primary key(a)) engine=innodb;
|
|
||||||
insert into t2 values (8,6),(12,1),(3,1);
|
|
||||||
commit;
|
|
||||||
set autocommit = 0;
|
|
||||||
select * from t2 for update;
|
|
||||||
a b
|
|
||||||
3 1
|
|
||||||
8 6
|
|
||||||
12 1
|
|
||||||
set autocommit = 0;
|
|
||||||
insert into t1 select * from t2 for update;
|
|
||||||
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
|
|
||||||
commit;
|
|
||||||
commit;
|
|
||||||
drop table t1, t2;
|
|
||||||
create table t1(a int not null, b int, primary key(a)) engine=innodb;
|
|
||||||
insert into t1 values (1,2),(5,3),(4,2);
|
|
||||||
create table t2(d int not null, e int, primary key(d)) engine=innodb;
|
|
||||||
insert into t2 values (1,6),(5,1),(4,1);
|
|
||||||
commit;
|
|
||||||
set autocommit = 0;
|
|
||||||
select * from t2 for update;
|
|
||||||
d e
|
|
||||||
1 6
|
|
||||||
4 1
|
|
||||||
5 1
|
|
||||||
set autocommit = 0;
|
|
||||||
update t1 set b = (select e from t2 where a = d for update);
|
|
||||||
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
|
|
||||||
commit;
|
|
||||||
commit;
|
|
||||||
drop table t1, t2;
|
|
||||||
create table t2(a int not null, b int, primary key(a)) engine=innodb;
|
|
||||||
insert into t2 values (1,6),(5,1),(4,1);
|
|
||||||
commit;
|
|
||||||
set autocommit = 0;
|
|
||||||
select * from t2 for update;
|
|
||||||
a b
|
|
||||||
1 6
|
|
||||||
4 1
|
|
||||||
5 1
|
|
||||||
set autocommit = 0;
|
|
||||||
create table t1(a int not null, b int, primary key(a)) engine=innodb select * from t2 for update;
|
|
||||||
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
|
|
||||||
commit;
|
|
||||||
commit;
|
|
||||||
drop table t2;
|
|
||||||
|
|||||||
@@ -87,13 +87,15 @@ disconnect b;
|
|||||||
# Consistent read should be used in following selects
|
# Consistent read should be used in following selects
|
||||||
#
|
#
|
||||||
# 1) INSERT INTO ... SELECT
|
# 1) INSERT INTO ... SELECT
|
||||||
|
# 2) UPDATE ... = ( SELECT ...)
|
||||||
|
# 3) CREATE ... SELECT
|
||||||
|
|
||||||
connect (a,localhost,root,,);
|
connect (a,localhost,root,,);
|
||||||
connect (b,localhost,root,,);
|
connect (b,localhost,root,,);
|
||||||
connection a;
|
connection a;
|
||||||
create table t1(a int not null, b int, primary key(a)) engine=innodb;
|
create table t1(a int not null, b int, primary key(a)) engine=innodb;
|
||||||
insert into t1 values (1,2),(5,3),(4,2);
|
insert into t1 values (1,2),(5,3),(4,2);
|
||||||
create table t2(a int not null, b int, primary key(a)) engine=innodb;
|
create table t2(d int not null, e int, primary key(d)) engine=innodb;
|
||||||
insert into t2 values (8,6),(12,1),(3,1);
|
insert into t2 values (8,6),(12,1),(3,1);
|
||||||
commit;
|
commit;
|
||||||
set autocommit = 0;
|
set autocommit = 0;
|
||||||
@@ -101,54 +103,8 @@ select * from t2 for update;
|
|||||||
connection b;
|
connection b;
|
||||||
set autocommit = 0;
|
set autocommit = 0;
|
||||||
insert into t1 select * from t2;
|
insert into t1 select * from t2;
|
||||||
commit;
|
|
||||||
connection a;
|
|
||||||
commit;
|
|
||||||
connection default;
|
|
||||||
disconnect a;
|
|
||||||
disconnect b;
|
|
||||||
drop table t1, t2;
|
|
||||||
|
|
||||||
#
|
|
||||||
# 2) UPDATE ... = ( SELECT ...)
|
|
||||||
#
|
|
||||||
|
|
||||||
connect (a,localhost,root,,);
|
|
||||||
connect (b,localhost,root,,);
|
|
||||||
connection a;
|
|
||||||
create table t1(a int not null, b int, primary key(a)) engine=innodb;
|
|
||||||
insert into t1 values (1,2),(5,3),(4,2);
|
|
||||||
create table t2(d int not null, e int, primary key(d)) engine=innodb;
|
|
||||||
insert into t2 values (1,6),(5,1),(4,1);
|
|
||||||
commit;
|
|
||||||
set autocommit = 0;
|
|
||||||
select * from t2 for update;
|
|
||||||
connection b;
|
|
||||||
set autocommit = 0;
|
|
||||||
update t1 set b = (select e from t2 where a = d);
|
update t1 set b = (select e from t2 where a = d);
|
||||||
commit;
|
create table t3(d int not null, e int, primary key(d)) engine=innodb
|
||||||
connection a;
|
|
||||||
commit;
|
|
||||||
connection default;
|
|
||||||
disconnect a;
|
|
||||||
disconnect b;
|
|
||||||
drop table t1, t2;
|
|
||||||
|
|
||||||
#
|
|
||||||
# 3) CREATE ... SELECT
|
|
||||||
#
|
|
||||||
|
|
||||||
connect (a,localhost,root,,);
|
|
||||||
connect (b,localhost,root,,);
|
|
||||||
connection a;
|
|
||||||
create table t2(a int not null, b int, primary key(a)) engine=innodb;
|
|
||||||
insert into t2 values (1,6),(5,1),(4,1);
|
|
||||||
commit;
|
|
||||||
set autocommit = 0;
|
|
||||||
select * from t2 for update;
|
|
||||||
connection b;
|
|
||||||
set autocommit = 0;
|
|
||||||
create table t1(a int not null, b int, primary key(a)) engine=innodb
|
|
||||||
select * from t2;
|
select * from t2;
|
||||||
commit;
|
commit;
|
||||||
connection a;
|
connection a;
|
||||||
@@ -156,244 +112,137 @@ commit;
|
|||||||
connection default;
|
connection default;
|
||||||
disconnect a;
|
disconnect a;
|
||||||
disconnect b;
|
disconnect b;
|
||||||
drop table t1, t2;
|
drop table t1, t2, t3;
|
||||||
|
|
||||||
#
|
#
|
||||||
# Consistent read should not be used if isolation level is serializable
|
# Consistent read should not be used if
|
||||||
|
#
|
||||||
|
# (a) isolation level is serializable OR
|
||||||
|
# (b) select ... lock in share mode OR
|
||||||
|
# (c) select ... for update
|
||||||
|
#
|
||||||
|
# in following queries:
|
||||||
#
|
#
|
||||||
|
|
||||||
# 1) INSERT INTO ... SELECT
|
# 1) INSERT INTO ... SELECT
|
||||||
|
# 2) UPDATE ... = ( SELECT ...)
|
||||||
|
# 3) CREATE ... SELECT
|
||||||
|
|
||||||
connect (a,localhost,root,,);
|
connect (a,localhost,root,,);
|
||||||
connect (b,localhost,root,,);
|
connect (b,localhost,root,,);
|
||||||
|
connect (c,localhost,root,,);
|
||||||
|
connect (d,localhost,root,,);
|
||||||
|
connect (e,localhost,root,,);
|
||||||
|
connect (f,localhost,root,,);
|
||||||
|
connect (g,localhost,root,,);
|
||||||
|
connect (h,localhost,root,,);
|
||||||
|
connect (i,localhost,root,,);
|
||||||
|
connect (j,localhost,root,,);
|
||||||
connection a;
|
connection a;
|
||||||
create table t1(a int not null, b int, primary key(a)) engine=innodb;
|
create table t1(a int not null, b int, primary key(a)) engine=innodb;
|
||||||
insert into t1 values (1,2),(5,3),(4,2);
|
insert into t1 values (1,2),(5,3),(4,2);
|
||||||
create table t2(a int not null, b int, primary key(a)) engine=innodb;
|
create table t2(a int not null, b int, primary key(a)) engine=innodb;
|
||||||
insert into t2 values (8,6),(12,1),(3,1);
|
insert into t2 values (8,6),(12,1),(3,1);
|
||||||
|
create table t3(d int not null, b int, primary key(d)) engine=innodb;
|
||||||
|
insert into t3 values (8,6),(12,1),(3,1);
|
||||||
|
create table t5(a int not null, b int, primary key(a)) engine=innodb;
|
||||||
|
insert into t5 values (1,2),(5,3),(4,2);
|
||||||
|
create table t6(d int not null, e int, primary key(d)) engine=innodb;
|
||||||
|
insert into t6 values (8,6),(12,1),(3,1);
|
||||||
|
create table t8(a int not null, b int, primary key(a)) engine=innodb;
|
||||||
|
insert into t8 values (1,2),(5,3),(4,2);
|
||||||
|
create table t9(d int not null, e int, primary key(d)) engine=innodb;
|
||||||
|
insert into t9 values (8,6),(12,1),(3,1);
|
||||||
commit;
|
commit;
|
||||||
set autocommit = 0;
|
set autocommit = 0;
|
||||||
select * from t2 for update;
|
select * from t2 for update;
|
||||||
connection b;
|
connection b;
|
||||||
set autocommit = 0;
|
set autocommit = 0;
|
||||||
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
|
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
|
||||||
--error 1205
|
--send
|
||||||
insert into t1 select * from t2;
|
insert into t1 select * from t2;
|
||||||
commit;
|
connection c;
|
||||||
connection a;
|
|
||||||
commit;
|
|
||||||
connection default;
|
|
||||||
disconnect a;
|
|
||||||
disconnect b;
|
|
||||||
drop table t1, t2;
|
|
||||||
|
|
||||||
#
|
|
||||||
# 2) UPDATE ... = ( SELECT ...)
|
|
||||||
#
|
|
||||||
|
|
||||||
connect (a,localhost,root,,);
|
|
||||||
connect (b,localhost,root,,);
|
|
||||||
connection a;
|
|
||||||
create table t1(a int not null, b int, primary key(a)) engine=innodb;
|
|
||||||
insert into t1 values (1,2),(5,3),(4,2);
|
|
||||||
create table t2(d int not null, e int, primary key(d)) engine=innodb;
|
|
||||||
insert into t2 values (1,6),(5,1),(4,1);
|
|
||||||
commit;
|
|
||||||
set autocommit = 0;
|
|
||||||
select * from t2 for update;
|
|
||||||
connection b;
|
|
||||||
set autocommit = 0;
|
set autocommit = 0;
|
||||||
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
|
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
|
||||||
--error 1205
|
--send
|
||||||
update t1 set b = (select e from t2 where a = d);
|
update t3 set b = (select b from t2 where a = d);
|
||||||
commit;
|
connection d;
|
||||||
connection a;
|
|
||||||
commit;
|
|
||||||
connection default;
|
|
||||||
disconnect a;
|
|
||||||
disconnect b;
|
|
||||||
drop table t1, t2;
|
|
||||||
|
|
||||||
#
|
|
||||||
# 3) CREATE ... SELECT
|
|
||||||
#
|
|
||||||
|
|
||||||
connect (a,localhost,root,,);
|
|
||||||
connect (b,localhost,root,,);
|
|
||||||
connection a;
|
|
||||||
create table t2(a int not null, b int, primary key(a)) engine=innodb;
|
|
||||||
insert into t2 values (1,6),(5,1),(4,1);
|
|
||||||
commit;
|
|
||||||
set autocommit = 0;
|
|
||||||
select * from t2 for update;
|
|
||||||
connection b;
|
|
||||||
set autocommit = 0;
|
set autocommit = 0;
|
||||||
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
|
SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
|
||||||
--error 1205
|
--send
|
||||||
create table t1(a int not null, b int, primary key(a)) engine=innodb
|
create table t4(a int not null, b int, primary key(a)) engine=innodb select * from t2;
|
||||||
select * from t2;
|
connection e;
|
||||||
commit;
|
|
||||||
connection a;
|
|
||||||
commit;
|
|
||||||
connection default;
|
|
||||||
disconnect a;
|
|
||||||
disconnect b;
|
|
||||||
drop table t2;
|
|
||||||
|
|
||||||
#
|
|
||||||
# Consistent read should not be used if locking read is used case
|
|
||||||
# (a) lock in share mode
|
|
||||||
#
|
|
||||||
|
|
||||||
# 1) INSERT INTO ... SELECT
|
|
||||||
|
|
||||||
connect (a,localhost,root,,);
|
|
||||||
connect (b,localhost,root,,);
|
|
||||||
connection a;
|
|
||||||
create table t1(a int not null, b int, primary key(a)) engine=innodb;
|
|
||||||
insert into t1 values (1,2),(5,3),(4,2);
|
|
||||||
create table t2(a int not null, b int, primary key(a)) engine=innodb;
|
|
||||||
insert into t2 values (8,6),(12,1),(3,1);
|
|
||||||
commit;
|
|
||||||
set autocommit = 0;
|
set autocommit = 0;
|
||||||
select * from t2 for update;
|
--send
|
||||||
|
insert into t5 (select * from t2 lock in share mode);
|
||||||
|
connection f;
|
||||||
|
set autocommit = 0;
|
||||||
|
--send
|
||||||
|
update t6 set e = (select b from t2 where a = d lock in share mode);
|
||||||
|
connection g;
|
||||||
|
set autocommit = 0;
|
||||||
|
--send
|
||||||
|
create table t7(a int not null, b int, primary key(a)) engine=innodb select * from t2 lock in share mode;
|
||||||
|
connection h;
|
||||||
|
set autocommit = 0;
|
||||||
|
--send
|
||||||
|
insert into t8 (select * from t2 for update);
|
||||||
|
connection i;
|
||||||
|
set autocommit = 0;
|
||||||
|
--send
|
||||||
|
update t9 set e = (select b from t2 where a = d for update);
|
||||||
|
connection j;
|
||||||
|
set autocommit = 0;
|
||||||
|
--send
|
||||||
|
create table t10(a int not null, b int, primary key(a)) engine=innodb select * from t2 for update;
|
||||||
|
|
||||||
connection b;
|
connection b;
|
||||||
set autocommit = 0;
|
|
||||||
--error 1205
|
--error 1205
|
||||||
insert into t1 select * from t2 lock in share mode;
|
reap;
|
||||||
commit;
|
|
||||||
|
connection c;
|
||||||
|
--error 1205
|
||||||
|
reap;
|
||||||
|
|
||||||
|
connection d;
|
||||||
|
--error 1205
|
||||||
|
reap;
|
||||||
|
|
||||||
|
connection e;
|
||||||
|
--error 1205
|
||||||
|
reap;
|
||||||
|
|
||||||
|
connection f;
|
||||||
|
--error 1205
|
||||||
|
reap;
|
||||||
|
|
||||||
|
connection g;
|
||||||
|
--error 1205
|
||||||
|
reap;
|
||||||
|
|
||||||
|
connection h;
|
||||||
|
--error 1205
|
||||||
|
reap;
|
||||||
|
|
||||||
|
connection i;
|
||||||
|
--error 1205
|
||||||
|
reap;
|
||||||
|
|
||||||
|
connection j;
|
||||||
|
--error 1205
|
||||||
|
reap;
|
||||||
|
|
||||||
connection a;
|
connection a;
|
||||||
commit;
|
commit;
|
||||||
|
|
||||||
connection default;
|
connection default;
|
||||||
disconnect a;
|
disconnect a;
|
||||||
disconnect b;
|
disconnect b;
|
||||||
drop table t1, t2;
|
disconnect c;
|
||||||
|
disconnect d;
|
||||||
#
|
disconnect e;
|
||||||
# 2) UPDATE ... = ( SELECT ...)
|
disconnect f;
|
||||||
#
|
disconnect g;
|
||||||
|
disconnect h;
|
||||||
connect (a,localhost,root,,);
|
disconnect i;
|
||||||
connect (b,localhost,root,,);
|
disconnect j;
|
||||||
connection a;
|
drop table t1, t2, t3, t5, t6, t8, t9;
|
||||||
create table t1(a int not null, b int, primary key(a)) engine=innodb;
|
|
||||||
insert into t1 values (1,2),(5,3),(4,2);
|
|
||||||
create table t2(d int not null, e int, primary key(d)) engine=innodb;
|
|
||||||
insert into t2 values (1,6),(5,1),(4,1);
|
|
||||||
commit;
|
|
||||||
set autocommit = 0;
|
|
||||||
select * from t2 for update;
|
|
||||||
connection b;
|
|
||||||
set autocommit = 0;
|
|
||||||
--error 1205
|
|
||||||
update t1 set b = (select e from t2 where a = d lock in share mode);
|
|
||||||
commit;
|
|
||||||
connection a;
|
|
||||||
commit;
|
|
||||||
connection default;
|
|
||||||
disconnect a;
|
|
||||||
disconnect b;
|
|
||||||
drop table t1, t2;
|
|
||||||
|
|
||||||
#
|
|
||||||
# 3) CREATE ... SELECT
|
|
||||||
#
|
|
||||||
|
|
||||||
connect (a,localhost,root,,);
|
|
||||||
connect (b,localhost,root,,);
|
|
||||||
connection a;
|
|
||||||
create table t2(a int not null, b int, primary key(a)) engine=innodb;
|
|
||||||
insert into t2 values (1,6),(5,1),(4,1);
|
|
||||||
commit;
|
|
||||||
set autocommit = 0;
|
|
||||||
select * from t2 for update;
|
|
||||||
connection b;
|
|
||||||
set autocommit = 0;
|
|
||||||
--error 1205
|
|
||||||
create table t1(a int not null, b int, primary key(a)) engine=innodb select * from t2 lock in share mode;
|
|
||||||
commit;
|
|
||||||
connection a;
|
|
||||||
commit;
|
|
||||||
connection default;
|
|
||||||
disconnect a;
|
|
||||||
disconnect b;
|
|
||||||
drop table t2;
|
|
||||||
|
|
||||||
#
|
|
||||||
# Consistent read should not be used if locking read is used case
|
|
||||||
# (b) for update
|
|
||||||
#
|
|
||||||
|
|
||||||
# 1) INSERT INTO ... SELECT
|
|
||||||
|
|
||||||
connect (a,localhost,root,,);
|
|
||||||
connect (b,localhost,root,,);
|
|
||||||
connection a;
|
|
||||||
create table t1(a int not null, b int, primary key(a)) engine=innodb;
|
|
||||||
insert into t1 values (1,2),(5,3),(4,2);
|
|
||||||
create table t2(a int not null, b int, primary key(a)) engine=innodb;
|
|
||||||
insert into t2 values (8,6),(12,1),(3,1);
|
|
||||||
commit;
|
|
||||||
set autocommit = 0;
|
|
||||||
select * from t2 for update;
|
|
||||||
connection b;
|
|
||||||
set autocommit = 0;
|
|
||||||
--error 1205
|
|
||||||
insert into t1 select * from t2 for update;
|
|
||||||
commit;
|
|
||||||
connection a;
|
|
||||||
commit;
|
|
||||||
connection default;
|
|
||||||
disconnect a;
|
|
||||||
disconnect b;
|
|
||||||
drop table t1, t2;
|
|
||||||
|
|
||||||
#
|
|
||||||
# 2) UPDATE ... = ( SELECT ...)
|
|
||||||
#
|
|
||||||
|
|
||||||
connect (a,localhost,root,,);
|
|
||||||
connect (b,localhost,root,,);
|
|
||||||
connection a;
|
|
||||||
create table t1(a int not null, b int, primary key(a)) engine=innodb;
|
|
||||||
insert into t1 values (1,2),(5,3),(4,2);
|
|
||||||
create table t2(d int not null, e int, primary key(d)) engine=innodb;
|
|
||||||
insert into t2 values (1,6),(5,1),(4,1);
|
|
||||||
commit;
|
|
||||||
set autocommit = 0;
|
|
||||||
select * from t2 for update;
|
|
||||||
connection b;
|
|
||||||
set autocommit = 0;
|
|
||||||
--error 1205
|
|
||||||
update t1 set b = (select e from t2 where a = d for update);
|
|
||||||
commit;
|
|
||||||
connection a;
|
|
||||||
commit;
|
|
||||||
connection default;
|
|
||||||
disconnect a;
|
|
||||||
disconnect b;
|
|
||||||
drop table t1, t2;
|
|
||||||
|
|
||||||
#
|
|
||||||
# 3) CREATE ... SELECT
|
|
||||||
#
|
|
||||||
|
|
||||||
connect (a,localhost,root,,);
|
|
||||||
connect (b,localhost,root,,);
|
|
||||||
connection a;
|
|
||||||
create table t2(a int not null, b int, primary key(a)) engine=innodb;
|
|
||||||
insert into t2 values (1,6),(5,1),(4,1);
|
|
||||||
commit;
|
|
||||||
set autocommit = 0;
|
|
||||||
select * from t2 for update;
|
|
||||||
connection b;
|
|
||||||
set autocommit = 0;
|
|
||||||
--error 1205
|
|
||||||
create table t1(a int not null, b int, primary key(a)) engine=innodb select * from t2 for update;
|
|
||||||
commit;
|
|
||||||
connection a;
|
|
||||||
commit;
|
|
||||||
connection default;
|
|
||||||
disconnect a;
|
|
||||||
disconnect b;
|
|
||||||
drop table t2;
|
|
||||||
|
|||||||
Reference in New Issue
Block a user