diff options
author | Sergey Vojtovich <svoj@mariadb.org> | 2019-05-16 17:48:47 +0400 |
---|---|---|
committer | Sergey Vojtovich <svoj@mariadb.org> | 2019-05-16 17:49:34 +0400 |
commit | 76a94a03db7ec2b4722a13f70c4eaf02debf70a5 (patch) | |
tree | 9a3143cb1ea5e1549515f2954d659b93c8abf811 /storage | |
parent | a24dffdba343c1e30a716b74c66ccf568f248523 (diff) | |
download | mariadb-git-76a94a03db7ec2b4722a13f70c4eaf02debf70a5.tar.gz |
MDEV-19090 - Split rocksdb.locking_issues
This test takes ~6 minutes, split it for better parallelism.
Diffstat (limited to 'storage')
42 files changed, 764 insertions, 739 deletions
diff --git a/storage/rocksdb/mysql-test/rocksdb/r/locking_issues.result b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues.result index d160b81f10e..84c93481c79 100644 --- a/storage/rocksdb/mysql-test/rocksdb/r/locking_issues.result +++ b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues.result @@ -1,674 +1 @@ - ------------------------------------------------------------------------ -- Locking issues case 1.1: -- Locking rows that do not exist when using all primary key columns in -- a WHERE clause -- using REPEATABLE READ transaction isolation level ------------------------------------------------------------------------ -DROP TABLE IF EXISTS t0; -CREATE TABLE t0(id1 INT, id2 INT, value INT, PRIMARY KEY(id1, id2)); -INSERT INTO t0 VALUES (1,1,0), (3,3,0), (4,4,0), (6,6,0); -connect con1,localhost,root,,; -connect con2,localhost,root,,; -connection con1; -SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; -BEGIN; -SELECT * FROM t0 WHERE id1=1 AND id2=5 FOR UPDATE; -id1 id2 value -connection con2; -SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; -BEGIN; -INSERT INTO t0 VALUES (1,5,0); -ERROR HY000: Lock wait timeout exceeded; try restarting transaction -SELECT * FROM t0 WHERE id1=1 AND id2=5 FOR UPDATE; -ERROR HY000: Lock wait timeout exceeded; try restarting transaction -connection con1; -COMMIT; -connection default; -disconnect con1; -disconnect con2; -DROP TABLE t0; - ------------------------------------------------------------------------ -- Locking issues case 1.1: -- Locking rows that do not exist when using all primary key columns in -- a WHERE clause -- using READ COMMITTED transaction isolation level ------------------------------------------------------------------------ -DROP TABLE IF EXISTS t0; -CREATE TABLE t0(id1 INT, id2 INT, value INT, PRIMARY KEY(id1, id2)); -INSERT INTO t0 VALUES (1,1,0), (3,3,0), (4,4,0), (6,6,0); -connect con1,localhost,root,,; -connect con2,localhost,root,,; -connection con1; -SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; -BEGIN; -SELECT * FROM t0 WHERE id1=1 AND id2=5 FOR UPDATE; -id1 id2 value -connection con2; -SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; -BEGIN; -INSERT INTO t0 VALUES (1,5,0); -ERROR HY000: Lock wait timeout exceeded; try restarting transaction -SELECT * FROM t0 WHERE id1=1 AND id2=5 FOR UPDATE; -ERROR HY000: Lock wait timeout exceeded; try restarting transaction -connection con1; -COMMIT; -connection default; -disconnect con1; -disconnect con2; -DROP TABLE t0; - ------------------------------------------------------------------------ -- Locking issues case 1.2: -- Locking rows that do not exist without using all primary key -- columns in a WHERE clause -- using REPEATABLE READ transaction isolation level ------------------------------------------------------------------------ -DROP TABLE IF EXISTS t0; -CREATE TABLE t0(id1 INT, id2 INT, value INT, PRIMARY KEY(id1, id2)); -INSERT INTO t0 VALUES (1,1,0), (3,3,0), (4,4,0), (6,6,0); -connect con1,localhost,root,,; -connect con2,localhost,root,,; -connection con1; -SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; -BEGIN; -SELECT * FROM t0 WHERE id1=1 FOR UPDATE; -id1 id2 value -1 1 0 -connection con2; -SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; -BEGIN; -SELECT * FROM t0 WHERE id1=1 AND id2=4 FOR UPDATE; -id1 id2 value -INSERT INTO t0 VALUES (1,5,0); -connection con1; -COMMIT; -connection default; -disconnect con1; -disconnect con2; -DROP TABLE t0; - ------------------------------------------------------------------------ -- Locking issues case 1.2: -- Locking rows that do not exist without using all primary key -- columns in a WHERE clause -- using READ COMMITTED transaction isolation level ------------------------------------------------------------------------ -DROP TABLE IF EXISTS t0; -CREATE TABLE t0(id1 INT, id2 INT, value INT, PRIMARY KEY(id1, id2)); -INSERT INTO t0 VALUES (1,1,0), (3,3,0), (4,4,0), (6,6,0); -connect con1,localhost,root,,; -connect con2,localhost,root,,; -connection con1; -SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; -BEGIN; -SELECT * FROM t0 WHERE id1=1 FOR UPDATE; -id1 id2 value -1 1 0 -connection con2; -SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; -BEGIN; -SELECT * FROM t0 WHERE id1=1 AND id2=4 FOR UPDATE; -id1 id2 value -INSERT INTO t0 VALUES (1,5,0); -connection con1; -COMMIT; -connection default; -disconnect con1; -disconnect con2; -DROP TABLE t0; - ------------------------------------------------------------------------ -- Locking issues case 2: -- Rows that are scanned but do not match the WHERE are not locked -- using REPEATABLE READ transaction isolation level unless -- rocksdb_lock_scanned_rows is on ------------------------------------------------------------------------ -DROP TABLE IF EXISTS t0; -SELECT @@global.rocksdb_lock_scanned_rows; -@@global.rocksdb_lock_scanned_rows -0 -CREATE TABLE t0(id INT PRIMARY KEY, value INT); -INSERT INTO t0 VALUES (1,0), (2,1), (3,0), (4,0), (5,1); -connect con1,localhost,root,,; -connect con2,localhost,root,,; -connection con1; -SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; -BEGIN; -connection con2; -SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; -BEGIN; -connection con1; -SELECT * FROM t0 WHERE value > 0 FOR UPDATE; -id value -2 1 -5 1 -connection con2; -UPDATE t0 SET VALUE=10 WHERE id=1; -UPDATE t0 SET VALUE=10 WHERE id=5; -ERROR HY000: Lock wait timeout exceeded; try restarting transaction -connection con1; -UPDATE t0 SET value=100 WHERE id in (4,5) and value>0; -connection con2; -SELECT * FROM t0 WHERE id=4 FOR UPDATE; -id value -4 0 -COMMIT; -SELECT * FROM t0; -id value -1 10 -2 1 -3 0 -4 0 -5 1 -connection con1; -COMMIT; -connection default; -disconnect con1; -disconnect con2; -DROP TABLE t0; - ------------------------------------------------------------------------ -- Locking issues case 2: -- Rows that are scanned but do not match the WHERE are not locked -- using READ COMMITTED transaction isolation level unless -- rocksdb_lock_scanned_rows is on ------------------------------------------------------------------------ -DROP TABLE IF EXISTS t0; -SELECT @@global.rocksdb_lock_scanned_rows; -@@global.rocksdb_lock_scanned_rows -0 -CREATE TABLE t0(id INT PRIMARY KEY, value INT); -INSERT INTO t0 VALUES (1,0), (2,1), (3,0), (4,0), (5,1); -connect con1,localhost,root,,; -connect con2,localhost,root,,; -connection con1; -SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; -BEGIN; -connection con2; -SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; -BEGIN; -connection con1; -SELECT * FROM t0 WHERE value > 0 FOR UPDATE; -id value -2 1 -5 1 -connection con2; -UPDATE t0 SET VALUE=10 WHERE id=1; -UPDATE t0 SET VALUE=10 WHERE id=5; -ERROR HY000: Lock wait timeout exceeded; try restarting transaction -connection con1; -UPDATE t0 SET value=100 WHERE id in (4,5) and value>0; -connection con2; -SELECT * FROM t0 WHERE id=4 FOR UPDATE; -id value -4 0 -COMMIT; -SELECT * FROM t0; -id value -1 10 -2 1 -3 0 -4 0 -5 1 -connection con1; -COMMIT; -connection default; -disconnect con1; -disconnect con2; -DROP TABLE t0; - ------------------------------------------------------------------------ -- Locking issues case 2: -- Rows that are scanned but do not match the WHERE are not locked -- using REPEATABLE READ transaction isolation level unless -- rocksdb_lock_scanned_rows is on ------------------------------------------------------------------------ -DROP TABLE IF EXISTS t0; -SELECT @@global.rocksdb_lock_scanned_rows; -@@global.rocksdb_lock_scanned_rows -0 -SET GLOBAL rocksdb_lock_scanned_rows=ON; -CREATE TABLE t0(id INT PRIMARY KEY, value INT); -INSERT INTO t0 VALUES (1,0), (2,1), (3,0), (4,0), (5,1); -connect con1,localhost,root,,; -connect con2,localhost,root,,; -connection con1; -SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; -BEGIN; -connection con2; -SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; -BEGIN; -connection con1; -SELECT * FROM t0 WHERE value > 0 FOR UPDATE; -id value -2 1 -5 1 -connection con2; -UPDATE t0 SET VALUE=10 WHERE id=1; -ERROR HY000: Lock wait timeout exceeded; try restarting transaction -connection con1; -COMMIT; -connection default; -disconnect con1; -disconnect con2; -DROP TABLE t0; -SET GLOBAL rocksdb_lock_scanned_rows=0; - ------------------------------------------------------------------------ -- Locking issues case 2: -- Rows that are scanned but do not match the WHERE are not locked -- using READ COMMITTED transaction isolation level unless -- rocksdb_lock_scanned_rows is on ------------------------------------------------------------------------ -DROP TABLE IF EXISTS t0; -SELECT @@global.rocksdb_lock_scanned_rows; -@@global.rocksdb_lock_scanned_rows -0 -SET GLOBAL rocksdb_lock_scanned_rows=ON; -CREATE TABLE t0(id INT PRIMARY KEY, value INT); -INSERT INTO t0 VALUES (1,0), (2,1), (3,0), (4,0), (5,1); -connect con1,localhost,root,,; -connect con2,localhost,root,,; -connection con1; -SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; -BEGIN; -connection con2; -SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; -BEGIN; -connection con1; -SELECT * FROM t0 WHERE value > 0 FOR UPDATE; -id value -2 1 -5 1 -connection con2; -UPDATE t0 SET VALUE=10 WHERE id=1; -ERROR HY000: Lock wait timeout exceeded; try restarting transaction -connection con1; -COMMIT; -connection default; -disconnect con1; -disconnect con2; -DROP TABLE t0; -SET GLOBAL rocksdb_lock_scanned_rows=0; - ------------------------------------------------------------------------ -- Locking issues case 3: -- After creating a snapshot, other clients updating rows -- using REPEATABLE READ transaction isolation level ------------------------------------------------------------------------ -DROP TABLE IF EXISTS t0; -CREATE TABLE t0(id INT AUTO_INCREMENT PRIMARY KEY, value INT); -Inserting 200,000 rows -connect con1,localhost,root,,; -connect con2,localhost,root,,; -connection con1; -SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; -SELECT * FROM t0 WHERE value > 0 FOR UPDATE; -connection con2; -SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; -UPDATE t0 SET VALUE=VALUE+1 WHERE id=190000; -connection con1; -ERROR: 1213 -connection default; -disconnect con1; -disconnect con2; -DROP TABLE t0; - ------------------------------------------------------------------------ -- Locking issues case 3: -- After creating a snapshot, other clients updating rows -- using READ COMMITTED transaction isolation level ------------------------------------------------------------------------ -DROP TABLE IF EXISTS t0; -CREATE TABLE t0(id INT AUTO_INCREMENT PRIMARY KEY, value INT); -Inserting 200,000 rows -connect con1,localhost,root,,; -connect con2,localhost,root,,; -connection con1; -SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; -SELECT * FROM t0 WHERE value > 0 FOR UPDATE; -connection con2; -SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; -UPDATE t0 SET VALUE=VALUE+1 WHERE id=190000; -connection con1; -id value -190000 1 -ERROR: 0 -connection default; -disconnect con1; -disconnect con2; -DROP TABLE t0; - ------------------------------------------------------------------------ -- Locking issues case 4: -- Phantom rows -- using REPEATABLE READ transaction isolation level ------------------------------------------------------------------------ -DROP TABLE IF EXISTS t0; -CREATE TABLE t0(id INT AUTO_INCREMENT PRIMARY KEY, value INT); -Inserting 200,000 rows -connect con1,localhost,root,,; -connect con2,localhost,root,,; -connection con1; -SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; -SELECT * FROM t0 WHERE value > 0 FOR UPDATE; -connection con2; -SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; -INSERT INTO t0 VALUES(200001,1), (-1,1); -connection con1; -id value -connection default; -disconnect con1; -disconnect con2; -DROP TABLE t0; - ------------------------------------------------------------------------ -- Locking issues case 4: -- Phantom rows -- using READ COMMITTED transaction isolation level ------------------------------------------------------------------------ -DROP TABLE IF EXISTS t0; -CREATE TABLE t0(id INT AUTO_INCREMENT PRIMARY KEY, value INT); -Inserting 200,000 rows -connect con1,localhost,root,,; -connect con2,localhost,root,,; -connection con1; -SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; -SELECT * FROM t0 WHERE value > 0 FOR UPDATE; -connection con2; -SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; -INSERT INTO t0 VALUES(200001,1), (-1,1); -connection con1; -id value -connection default; -disconnect con1; -disconnect con2; -DROP TABLE t0; - ------------------------------------------------------------------------ -- Locking issues case 5: -- Deleting primary key -- using REPEATABLE READ transaction isolation level ------------------------------------------------------------------------ -DROP TABLE IF EXISTS t0; -CREATE TABLE t0(id INT AUTO_INCREMENT PRIMARY KEY, value INT); -Inserting 200,000 rows -UPDATE t0 SET value=100 WHERE id=190000; -connect con1,localhost,root,,; -connect con2,localhost,root,,; -connection con1; -SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; -BEGIN; -SELECT * FROM t0 WHERE value > 0 FOR UPDATE; -connection con2; -SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; -BEGIN; -DELETE FROM t0 WHERE id=190000; -COMMIT; -connection con1; -ERROR: 1213 -COMMIT; -connection default; -disconnect con1; -disconnect con2; -DROP TABLE t0; - ------------------------------------------------------------------------ -- Locking issues case 5: -- Deleting primary key -- using READ COMMITTED transaction isolation level ------------------------------------------------------------------------ -DROP TABLE IF EXISTS t0; -CREATE TABLE t0(id INT AUTO_INCREMENT PRIMARY KEY, value INT); -Inserting 200,000 rows -UPDATE t0 SET value=100 WHERE id=190000; -connect con1,localhost,root,,; -connect con2,localhost,root,,; -connection con1; -SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; -BEGIN; -SELECT * FROM t0 WHERE value > 0 FOR UPDATE; -connection con2; -SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; -BEGIN; -DELETE FROM t0 WHERE id=190000; -COMMIT; -connection con1; -id value -ERROR: 0 -COMMIT; -connection default; -disconnect con1; -disconnect con2; -DROP TABLE t0; - ------------------------------------------------------------------------ -- Locking issues case 6: -- Changing primary key -- using REPEATABLE READ transaction isolation level ------------------------------------------------------------------------ -DROP TABLE IF EXISTS t0; -CREATE TABLE t0(id INT AUTO_INCREMENT PRIMARY KEY, value INT); -Inserting 200,000 rows -UPDATE t0 SET value=100 WHERE id=190000; -connect con1,localhost,root,,; -connect con2,localhost,root,,; -connection con1; -SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; -BEGIN; -SELECT * FROM t0 WHERE value > 0 FOR UPDATE; -connection con2; -SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; -BEGIN; -UPDATE t0 SET id=200001 WHERE id=190000; -COMMIT; -connection con1; -ERROR: 1213 -COMMIT; -connection default; -disconnect con1; -disconnect con2; -DROP TABLE t0; - ------------------------------------------------------------------------ -- Locking issues case 6: -- Changing primary key -- using READ COMMITTED transaction isolation level ------------------------------------------------------------------------ -DROP TABLE IF EXISTS t0; -CREATE TABLE t0(id INT AUTO_INCREMENT PRIMARY KEY, value INT); -Inserting 200,000 rows -UPDATE t0 SET value=100 WHERE id=190000; -connect con1,localhost,root,,; -connect con2,localhost,root,,; -connection con1; -SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; -BEGIN; -SELECT * FROM t0 WHERE value > 0 FOR UPDATE; -connection con2; -SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; -BEGIN; -UPDATE t0 SET id=200001 WHERE id=190000; -COMMIT; -connection con1; -id value -ERROR: 0 -COMMIT; -connection default; -disconnect con1; -disconnect con2; -DROP TABLE t0; - ------------------------------------------------------------------------ -- Locking issues case 7: -- Rows that are scanned as part of a query but not in the table being -- updated should not be locked unless rocksdb_lock_scanned_rows is on ------------------------------------------------------------------------ -DROP TABLE IF EXISTS t1, t2; -SELECT @@global.rocksdb_lock_scanned_rows; -@@global.rocksdb_lock_scanned_rows -0 -CREATE TABLE t1(id INT PRIMARY KEY, value INT); -CREATE TABLE t2(id INT PRIMARY KEY, value INT); -INSERT INTO t1 VALUES (1,1), (2,2), (3,3); -INSERT INTO t2 VALUES (1,1), (2,2), (3,3), (4,4), (5,5); -connect con1,localhost,root,,; -connect con2,localhost,root,,; -connection con1; -SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; -BEGIN; -connection con2; -SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; -BEGIN; -lock_scanned_rows is 0 -connection con1; -UPDATE t1 JOIN t2 ON t1.id = t2.id SET t1.value=t1.value+100 WHERE t2.id=3; -connection con2; -UPDATE t2 SET value=value+100; -SELECT * FROM t2; -id value -1 101 -2 102 -3 103 -4 104 -5 105 -connection con1; -COMMIT; -connection default; -disconnect con1; -disconnect con2; -DROP TABLE t1; -DROP TABLE t2; - ------------------------------------------------------------------------ -- Locking issues case 7: -- Rows that are scanned as part of a query but not in the table being -- updated should not be locked unless rocksdb_lock_scanned_rows is on ------------------------------------------------------------------------ -DROP TABLE IF EXISTS t1, t2; -SELECT @@global.rocksdb_lock_scanned_rows; -@@global.rocksdb_lock_scanned_rows -0 -CREATE TABLE t1(id INT PRIMARY KEY, value INT); -CREATE TABLE t2(id INT PRIMARY KEY, value INT); -INSERT INTO t1 VALUES (1,1), (2,2), (3,3); -INSERT INTO t2 VALUES (1,1), (2,2), (3,3), (4,4), (5,5); -connect con1,localhost,root,,; -connect con2,localhost,root,,; -connection con1; -SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; -BEGIN; -connection con2; -SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; -BEGIN; -lock_scanned_rows is 0 -connection con1; -UPDATE t1 JOIN t2 ON t1.id = t2.id SET t1.value=t1.value+100 WHERE t2.id=3; -connection con2; -UPDATE t2 SET value=value+100; -SELECT * FROM t2; -id value -1 101 -2 102 -3 103 -4 104 -5 105 -connection con1; -COMMIT; -connection default; -disconnect con1; -disconnect con2; -DROP TABLE t1; -DROP TABLE t2; - ------------------------------------------------------------------------ -- Locking issues case 7: -- Rows that are scanned as part of a query but not in the table being -- updated should not be locked unless rocksdb_lock_scanned_rows is on ------------------------------------------------------------------------ -DROP TABLE IF EXISTS t1, t2; -SELECT @@global.rocksdb_lock_scanned_rows; -@@global.rocksdb_lock_scanned_rows -0 -SET GLOBAL rocksdb_lock_scanned_rows=ON; -CREATE TABLE t1(id INT PRIMARY KEY, value INT); -CREATE TABLE t2(id INT PRIMARY KEY, value INT); -INSERT INTO t1 VALUES (1,1), (2,2), (3,3); -INSERT INTO t2 VALUES (1,1), (2,2), (3,3), (4,4), (5,5); -connect con1,localhost,root,,; -connect con2,localhost,root,,; -connection con1; -SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; -BEGIN; -connection con2; -SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; -BEGIN; -lock_scanned_rows is 1 -connection con1; -UPDATE t1 JOIN t2 ON t1.id = t2.id SET t1.value=t1.value+100 WHERE t2.id=3; -connection con2; -UPDATE t2 SET value=value+100 WHERE id=3; -ERROR HY000: Lock wait timeout exceeded; try restarting transaction -UPDATE t2 SET value=value+100 WHERE id IN (1,2,4,5); -SELECT * FROM t2; -id value -1 101 -2 102 -3 3 -4 104 -5 105 -connection con1; -COMMIT; -connection default; -disconnect con1; -disconnect con2; -DROP TABLE t1; -DROP TABLE t2; -SET GLOBAL rocksdb_lock_scanned_rows=0; - ------------------------------------------------------------------------ -- Locking issues case 7: -- Rows that are scanned as part of a query but not in the table being -- updated should not be locked unless rocksdb_lock_scanned_rows is on ------------------------------------------------------------------------ -DROP TABLE IF EXISTS t1, t2; -SELECT @@global.rocksdb_lock_scanned_rows; -@@global.rocksdb_lock_scanned_rows -0 -SET GLOBAL rocksdb_lock_scanned_rows=ON; -CREATE TABLE t1(id INT PRIMARY KEY, value INT); -CREATE TABLE t2(id INT PRIMARY KEY, value INT); -INSERT INTO t1 VALUES (1,1), (2,2), (3,3); -INSERT INTO t2 VALUES (1,1), (2,2), (3,3), (4,4), (5,5); -connect con1,localhost,root,,; -connect con2,localhost,root,,; -connection con1; -SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; -BEGIN; -connection con2; -SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; -BEGIN; -lock_scanned_rows is 1 -connection con1; -UPDATE t1 JOIN t2 ON t1.id = t2.id SET t1.value=t1.value+100 WHERE t2.id=3; -connection con2; -UPDATE t2 SET value=value+100 WHERE id=3; -ERROR HY000: Lock wait timeout exceeded; try restarting transaction -UPDATE t2 SET value=value+100 WHERE id IN (1,2,4,5); -SELECT * FROM t2; -id value -1 101 -2 102 -3 3 -4 104 -5 105 -connection con1; -COMMIT; -connection default; -disconnect con1; -disconnect con2; -DROP TABLE t1; -DROP TABLE t2; -SET GLOBAL rocksdb_lock_scanned_rows=0; +tests moved to rocksdb.locking_issues_case* diff --git a/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case1_1_rc.result b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case1_1_rc.result new file mode 100644 index 00000000000..a47aa3c7d90 --- /dev/null +++ b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case1_1_rc.result @@ -0,0 +1,30 @@ + +----------------------------------------------------------------------- +- Locking issues case 1.1: +- Locking rows that do not exist when using all primary key columns in +- a WHERE clause +- using READ COMMITTED transaction isolation level +----------------------------------------------------------------------- +DROP TABLE IF EXISTS t0; +CREATE TABLE t0(id1 INT, id2 INT, value INT, PRIMARY KEY(id1, id2)); +INSERT INTO t0 VALUES (1,1,0), (3,3,0), (4,4,0), (6,6,0); +connect con1,localhost,root,,; +connect con2,localhost,root,,; +connection con1; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +BEGIN; +SELECT * FROM t0 WHERE id1=1 AND id2=5 FOR UPDATE; +id1 id2 value +connection con2; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +BEGIN; +INSERT INTO t0 VALUES (1,5,0); +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +SELECT * FROM t0 WHERE id1=1 AND id2=5 FOR UPDATE; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +connection con1; +COMMIT; +connection default; +disconnect con1; +disconnect con2; +DROP TABLE t0; diff --git a/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case1_1_rr.result b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case1_1_rr.result new file mode 100644 index 00000000000..c923c34c98e --- /dev/null +++ b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case1_1_rr.result @@ -0,0 +1,30 @@ + +----------------------------------------------------------------------- +- Locking issues case 1.1: +- Locking rows that do not exist when using all primary key columns in +- a WHERE clause +- using REPEATABLE READ transaction isolation level +----------------------------------------------------------------------- +DROP TABLE IF EXISTS t0; +CREATE TABLE t0(id1 INT, id2 INT, value INT, PRIMARY KEY(id1, id2)); +INSERT INTO t0 VALUES (1,1,0), (3,3,0), (4,4,0), (6,6,0); +connect con1,localhost,root,,; +connect con2,localhost,root,,; +connection con1; +SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; +BEGIN; +SELECT * FROM t0 WHERE id1=1 AND id2=5 FOR UPDATE; +id1 id2 value +connection con2; +SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; +BEGIN; +INSERT INTO t0 VALUES (1,5,0); +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +SELECT * FROM t0 WHERE id1=1 AND id2=5 FOR UPDATE; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +connection con1; +COMMIT; +connection default; +disconnect con1; +disconnect con2; +DROP TABLE t0; diff --git a/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case1_2_rc.result b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case1_2_rc.result new file mode 100644 index 00000000000..01c4e7e3b2f --- /dev/null +++ b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case1_2_rc.result @@ -0,0 +1,30 @@ + +----------------------------------------------------------------------- +- Locking issues case 1.2: +- Locking rows that do not exist without using all primary key +- columns in a WHERE clause +- using READ COMMITTED transaction isolation level +----------------------------------------------------------------------- +DROP TABLE IF EXISTS t0; +CREATE TABLE t0(id1 INT, id2 INT, value INT, PRIMARY KEY(id1, id2)); +INSERT INTO t0 VALUES (1,1,0), (3,3,0), (4,4,0), (6,6,0); +connect con1,localhost,root,,; +connect con2,localhost,root,,; +connection con1; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +BEGIN; +SELECT * FROM t0 WHERE id1=1 FOR UPDATE; +id1 id2 value +1 1 0 +connection con2; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +BEGIN; +SELECT * FROM t0 WHERE id1=1 AND id2=4 FOR UPDATE; +id1 id2 value +INSERT INTO t0 VALUES (1,5,0); +connection con1; +COMMIT; +connection default; +disconnect con1; +disconnect con2; +DROP TABLE t0; diff --git a/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case1_2_rr.result b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case1_2_rr.result new file mode 100644 index 00000000000..798fd15b76e --- /dev/null +++ b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case1_2_rr.result @@ -0,0 +1,30 @@ + +----------------------------------------------------------------------- +- Locking issues case 1.2: +- Locking rows that do not exist without using all primary key +- columns in a WHERE clause +- using REPEATABLE READ transaction isolation level +----------------------------------------------------------------------- +DROP TABLE IF EXISTS t0; +CREATE TABLE t0(id1 INT, id2 INT, value INT, PRIMARY KEY(id1, id2)); +INSERT INTO t0 VALUES (1,1,0), (3,3,0), (4,4,0), (6,6,0); +connect con1,localhost,root,,; +connect con2,localhost,root,,; +connection con1; +SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; +BEGIN; +SELECT * FROM t0 WHERE id1=1 FOR UPDATE; +id1 id2 value +1 1 0 +connection con2; +SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; +BEGIN; +SELECT * FROM t0 WHERE id1=1 AND id2=4 FOR UPDATE; +id1 id2 value +INSERT INTO t0 VALUES (1,5,0); +connection con1; +COMMIT; +connection default; +disconnect con1; +disconnect con2; +DROP TABLE t0; diff --git a/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case2_rc.result b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case2_rc.result new file mode 100644 index 00000000000..16480da8e80 --- /dev/null +++ b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case2_rc.result @@ -0,0 +1,50 @@ + +----------------------------------------------------------------------- +- Locking issues case 2: +- Rows that are scanned but do not match the WHERE are not locked +- using READ COMMITTED transaction isolation level unless +- rocksdb_lock_scanned_rows is on +----------------------------------------------------------------------- +DROP TABLE IF EXISTS t0; +SELECT @@global.rocksdb_lock_scanned_rows; +@@global.rocksdb_lock_scanned_rows +0 +CREATE TABLE t0(id INT PRIMARY KEY, value INT); +INSERT INTO t0 VALUES (1,0), (2,1), (3,0), (4,0), (5,1); +connect con1,localhost,root,,; +connect con2,localhost,root,,; +connection con1; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +BEGIN; +connection con2; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +BEGIN; +connection con1; +SELECT * FROM t0 WHERE value > 0 FOR UPDATE; +id value +2 1 +5 1 +connection con2; +UPDATE t0 SET VALUE=10 WHERE id=1; +UPDATE t0 SET VALUE=10 WHERE id=5; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +connection con1; +UPDATE t0 SET value=100 WHERE id in (4,5) and value>0; +connection con2; +SELECT * FROM t0 WHERE id=4 FOR UPDATE; +id value +4 0 +COMMIT; +SELECT * FROM t0; +id value +1 10 +2 1 +3 0 +4 0 +5 1 +connection con1; +COMMIT; +connection default; +disconnect con1; +disconnect con2; +DROP TABLE t0; diff --git a/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case2_rc_lsr.result b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case2_rc_lsr.result new file mode 100644 index 00000000000..330cd09d33e --- /dev/null +++ b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case2_rc_lsr.result @@ -0,0 +1,37 @@ + +----------------------------------------------------------------------- +- Locking issues case 2: +- Rows that are scanned but do not match the WHERE are not locked +- using READ COMMITTED transaction isolation level unless +- rocksdb_lock_scanned_rows is on +----------------------------------------------------------------------- +DROP TABLE IF EXISTS t0; +SELECT @@global.rocksdb_lock_scanned_rows; +@@global.rocksdb_lock_scanned_rows +0 +SET GLOBAL rocksdb_lock_scanned_rows=ON; +CREATE TABLE t0(id INT PRIMARY KEY, value INT); +INSERT INTO t0 VALUES (1,0), (2,1), (3,0), (4,0), (5,1); +connect con1,localhost,root,,; +connect con2,localhost,root,,; +connection con1; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +BEGIN; +connection con2; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +BEGIN; +connection con1; +SELECT * FROM t0 WHERE value > 0 FOR UPDATE; +id value +2 1 +5 1 +connection con2; +UPDATE t0 SET VALUE=10 WHERE id=1; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +connection con1; +COMMIT; +connection default; +disconnect con1; +disconnect con2; +DROP TABLE t0; +SET GLOBAL rocksdb_lock_scanned_rows=0; diff --git a/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case2_rr.result b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case2_rr.result new file mode 100644 index 00000000000..3e6b63afaa8 --- /dev/null +++ b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case2_rr.result @@ -0,0 +1,50 @@ + +----------------------------------------------------------------------- +- Locking issues case 2: +- Rows that are scanned but do not match the WHERE are not locked +- using REPEATABLE READ transaction isolation level unless +- rocksdb_lock_scanned_rows is on +----------------------------------------------------------------------- +DROP TABLE IF EXISTS t0; +SELECT @@global.rocksdb_lock_scanned_rows; +@@global.rocksdb_lock_scanned_rows +0 +CREATE TABLE t0(id INT PRIMARY KEY, value INT); +INSERT INTO t0 VALUES (1,0), (2,1), (3,0), (4,0), (5,1); +connect con1,localhost,root,,; +connect con2,localhost,root,,; +connection con1; +SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; +BEGIN; +connection con2; +SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; +BEGIN; +connection con1; +SELECT * FROM t0 WHERE value > 0 FOR UPDATE; +id value +2 1 +5 1 +connection con2; +UPDATE t0 SET VALUE=10 WHERE id=1; +UPDATE t0 SET VALUE=10 WHERE id=5; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +connection con1; +UPDATE t0 SET value=100 WHERE id in (4,5) and value>0; +connection con2; +SELECT * FROM t0 WHERE id=4 FOR UPDATE; +id value +4 0 +COMMIT; +SELECT * FROM t0; +id value +1 10 +2 1 +3 0 +4 0 +5 1 +connection con1; +COMMIT; +connection default; +disconnect con1; +disconnect con2; +DROP TABLE t0; diff --git a/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case2_rr_lsr.result b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case2_rr_lsr.result new file mode 100644 index 00000000000..088e975ebc5 --- /dev/null +++ b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case2_rr_lsr.result @@ -0,0 +1,37 @@ + +----------------------------------------------------------------------- +- Locking issues case 2: +- Rows that are scanned but do not match the WHERE are not locked +- using REPEATABLE READ transaction isolation level unless +- rocksdb_lock_scanned_rows is on +----------------------------------------------------------------------- +DROP TABLE IF EXISTS t0; +SELECT @@global.rocksdb_lock_scanned_rows; +@@global.rocksdb_lock_scanned_rows +0 +SET GLOBAL rocksdb_lock_scanned_rows=ON; +CREATE TABLE t0(id INT PRIMARY KEY, value INT); +INSERT INTO t0 VALUES (1,0), (2,1), (3,0), (4,0), (5,1); +connect con1,localhost,root,,; +connect con2,localhost,root,,; +connection con1; +SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; +BEGIN; +connection con2; +SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; +BEGIN; +connection con1; +SELECT * FROM t0 WHERE value > 0 FOR UPDATE; +id value +2 1 +5 1 +connection con2; +UPDATE t0 SET VALUE=10 WHERE id=1; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +connection con1; +COMMIT; +connection default; +disconnect con1; +disconnect con2; +DROP TABLE t0; +SET GLOBAL rocksdb_lock_scanned_rows=0; diff --git a/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case3_rc.result b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case3_rc.result new file mode 100644 index 00000000000..9a6f02cd41d --- /dev/null +++ b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case3_rc.result @@ -0,0 +1,25 @@ + +----------------------------------------------------------------------- +- Locking issues case 3: +- After creating a snapshot, other clients updating rows +- using READ COMMITTED transaction isolation level +----------------------------------------------------------------------- +DROP TABLE IF EXISTS t0; +CREATE TABLE t0(id INT AUTO_INCREMENT PRIMARY KEY, value INT); +Inserting 200,000 rows +connect con1,localhost,root,,; +connect con2,localhost,root,,; +connection con1; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +SELECT * FROM t0 WHERE value > 0 FOR UPDATE; +connection con2; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +UPDATE t0 SET VALUE=VALUE+1 WHERE id=190000; +connection con1; +id value +190000 1 +ERROR: 0 +connection default; +disconnect con1; +disconnect con2; +DROP TABLE t0; diff --git a/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case3_rr.result b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case3_rr.result new file mode 100644 index 00000000000..fdd4d8fcaca --- /dev/null +++ b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case3_rr.result @@ -0,0 +1,23 @@ + +----------------------------------------------------------------------- +- Locking issues case 3: +- After creating a snapshot, other clients updating rows +- using REPEATABLE READ transaction isolation level +----------------------------------------------------------------------- +DROP TABLE IF EXISTS t0; +CREATE TABLE t0(id INT AUTO_INCREMENT PRIMARY KEY, value INT); +Inserting 200,000 rows +connect con1,localhost,root,,; +connect con2,localhost,root,,; +connection con1; +SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; +SELECT * FROM t0 WHERE value > 0 FOR UPDATE; +connection con2; +SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; +UPDATE t0 SET VALUE=VALUE+1 WHERE id=190000; +connection con1; +ERROR: 1213 +connection default; +disconnect con1; +disconnect con2; +DROP TABLE t0; diff --git a/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case4_rc.result b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case4_rc.result new file mode 100644 index 00000000000..1a35d276192 --- /dev/null +++ b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case4_rc.result @@ -0,0 +1,23 @@ + +----------------------------------------------------------------------- +- Locking issues case 4: +- Phantom rows +- using READ COMMITTED transaction isolation level +----------------------------------------------------------------------- +DROP TABLE IF EXISTS t0; +CREATE TABLE t0(id INT AUTO_INCREMENT PRIMARY KEY, value INT); +Inserting 200,000 rows +connect con1,localhost,root,,; +connect con2,localhost,root,,; +connection con1; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +SELECT * FROM t0 WHERE value > 0 FOR UPDATE; +connection con2; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +INSERT INTO t0 VALUES(200001,1), (-1,1); +connection con1; +id value +connection default; +disconnect con1; +disconnect con2; +DROP TABLE t0; diff --git a/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case4_rr.result b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case4_rr.result new file mode 100644 index 00000000000..7ecb1ac5f7a --- /dev/null +++ b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case4_rr.result @@ -0,0 +1,23 @@ + +----------------------------------------------------------------------- +- Locking issues case 4: +- Phantom rows +- using REPEATABLE READ transaction isolation level +----------------------------------------------------------------------- +DROP TABLE IF EXISTS t0; +CREATE TABLE t0(id INT AUTO_INCREMENT PRIMARY KEY, value INT); +Inserting 200,000 rows +connect con1,localhost,root,,; +connect con2,localhost,root,,; +connection con1; +SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; +SELECT * FROM t0 WHERE value > 0 FOR UPDATE; +connection con2; +SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; +INSERT INTO t0 VALUES(200001,1), (-1,1); +connection con1; +id value +connection default; +disconnect con1; +disconnect con2; +DROP TABLE t0; diff --git a/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case5_rc.result b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case5_rc.result new file mode 100644 index 00000000000..4d707e83eec --- /dev/null +++ b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case5_rc.result @@ -0,0 +1,29 @@ + +----------------------------------------------------------------------- +- Locking issues case 5: +- Deleting primary key +- using READ COMMITTED transaction isolation level +----------------------------------------------------------------------- +DROP TABLE IF EXISTS t0; +CREATE TABLE t0(id INT AUTO_INCREMENT PRIMARY KEY, value INT); +Inserting 200,000 rows +UPDATE t0 SET value=100 WHERE id=190000; +connect con1,localhost,root,,; +connect con2,localhost,root,,; +connection con1; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +BEGIN; +SELECT * FROM t0 WHERE value > 0 FOR UPDATE; +connection con2; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +BEGIN; +DELETE FROM t0 WHERE id=190000; +COMMIT; +connection con1; +id value +ERROR: 0 +COMMIT; +connection default; +disconnect con1; +disconnect con2; +DROP TABLE t0; diff --git a/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case5_rr.result b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case5_rr.result new file mode 100644 index 00000000000..0ebfe8e6079 --- /dev/null +++ b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case5_rr.result @@ -0,0 +1,28 @@ + +----------------------------------------------------------------------- +- Locking issues case 5: +- Deleting primary key +- using REPEATABLE READ transaction isolation level +----------------------------------------------------------------------- +DROP TABLE IF EXISTS t0; +CREATE TABLE t0(id INT AUTO_INCREMENT PRIMARY KEY, value INT); +Inserting 200,000 rows +UPDATE t0 SET value=100 WHERE id=190000; +connect con1,localhost,root,,; +connect con2,localhost,root,,; +connection con1; +SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; +BEGIN; +SELECT * FROM t0 WHERE value > 0 FOR UPDATE; +connection con2; +SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; +BEGIN; +DELETE FROM t0 WHERE id=190000; +COMMIT; +connection con1; +ERROR: 1213 +COMMIT; +connection default; +disconnect con1; +disconnect con2; +DROP TABLE t0; diff --git a/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case6_rc.result b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case6_rc.result new file mode 100644 index 00000000000..f16ffbeaa63 --- /dev/null +++ b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case6_rc.result @@ -0,0 +1,29 @@ + +----------------------------------------------------------------------- +- Locking issues case 6: +- Changing primary key +- using READ COMMITTED transaction isolation level +----------------------------------------------------------------------- +DROP TABLE IF EXISTS t0; +CREATE TABLE t0(id INT AUTO_INCREMENT PRIMARY KEY, value INT); +Inserting 200,000 rows +UPDATE t0 SET value=100 WHERE id=190000; +connect con1,localhost,root,,; +connect con2,localhost,root,,; +connection con1; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +BEGIN; +SELECT * FROM t0 WHERE value > 0 FOR UPDATE; +connection con2; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +BEGIN; +UPDATE t0 SET id=200001 WHERE id=190000; +COMMIT; +connection con1; +id value +ERROR: 0 +COMMIT; +connection default; +disconnect con1; +disconnect con2; +DROP TABLE t0; diff --git a/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case6_rr.result b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case6_rr.result new file mode 100644 index 00000000000..c2323937d15 --- /dev/null +++ b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case6_rr.result @@ -0,0 +1,28 @@ + +----------------------------------------------------------------------- +- Locking issues case 6: +- Changing primary key +- using REPEATABLE READ transaction isolation level +----------------------------------------------------------------------- +DROP TABLE IF EXISTS t0; +CREATE TABLE t0(id INT AUTO_INCREMENT PRIMARY KEY, value INT); +Inserting 200,000 rows +UPDATE t0 SET value=100 WHERE id=190000; +connect con1,localhost,root,,; +connect con2,localhost,root,,; +connection con1; +SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; +BEGIN; +SELECT * FROM t0 WHERE value > 0 FOR UPDATE; +connection con2; +SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; +BEGIN; +UPDATE t0 SET id=200001 WHERE id=190000; +COMMIT; +connection con1; +ERROR: 1213 +COMMIT; +connection default; +disconnect con1; +disconnect con2; +DROP TABLE t0; diff --git a/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case7_rc.result b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case7_rc.result new file mode 100644 index 00000000000..f30dbab045d --- /dev/null +++ b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case7_rc.result @@ -0,0 +1,41 @@ + +----------------------------------------------------------------------- +- Locking issues case 7: +- Rows that are scanned as part of a query but not in the table being +- updated should not be locked unless rocksdb_lock_scanned_rows is on +----------------------------------------------------------------------- +DROP TABLE IF EXISTS t1, t2; +SELECT @@global.rocksdb_lock_scanned_rows; +@@global.rocksdb_lock_scanned_rows +0 +CREATE TABLE t1(id INT PRIMARY KEY, value INT); +CREATE TABLE t2(id INT PRIMARY KEY, value INT); +INSERT INTO t1 VALUES (1,1), (2,2), (3,3); +INSERT INTO t2 VALUES (1,1), (2,2), (3,3), (4,4), (5,5); +connect con1,localhost,root,,; +connect con2,localhost,root,,; +connection con1; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +BEGIN; +connection con2; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +BEGIN; +lock_scanned_rows is 0 +connection con1; +UPDATE t1 JOIN t2 ON t1.id = t2.id SET t1.value=t1.value+100 WHERE t2.id=3; +connection con2; +UPDATE t2 SET value=value+100; +SELECT * FROM t2; +id value +1 101 +2 102 +3 103 +4 104 +5 105 +connection con1; +COMMIT; +connection default; +disconnect con1; +disconnect con2; +DROP TABLE t1; +DROP TABLE t2; diff --git a/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case7_rc_lsr.result b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case7_rc_lsr.result new file mode 100644 index 00000000000..d43e3efbfe0 --- /dev/null +++ b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case7_rc_lsr.result @@ -0,0 +1,45 @@ + +----------------------------------------------------------------------- +- Locking issues case 7: +- Rows that are scanned as part of a query but not in the table being +- updated should not be locked unless rocksdb_lock_scanned_rows is on +----------------------------------------------------------------------- +DROP TABLE IF EXISTS t1, t2; +SELECT @@global.rocksdb_lock_scanned_rows; +@@global.rocksdb_lock_scanned_rows +0 +SET GLOBAL rocksdb_lock_scanned_rows=ON; +CREATE TABLE t1(id INT PRIMARY KEY, value INT); +CREATE TABLE t2(id INT PRIMARY KEY, value INT); +INSERT INTO t1 VALUES (1,1), (2,2), (3,3); +INSERT INTO t2 VALUES (1,1), (2,2), (3,3), (4,4), (5,5); +connect con1,localhost,root,,; +connect con2,localhost,root,,; +connection con1; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +BEGIN; +connection con2; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +BEGIN; +lock_scanned_rows is 1 +connection con1; +UPDATE t1 JOIN t2 ON t1.id = t2.id SET t1.value=t1.value+100 WHERE t2.id=3; +connection con2; +UPDATE t2 SET value=value+100 WHERE id=3; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +UPDATE t2 SET value=value+100 WHERE id IN (1,2,4,5); +SELECT * FROM t2; +id value +1 101 +2 102 +3 3 +4 104 +5 105 +connection con1; +COMMIT; +connection default; +disconnect con1; +disconnect con2; +DROP TABLE t1; +DROP TABLE t2; +SET GLOBAL rocksdb_lock_scanned_rows=0; diff --git a/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case7_rr.result b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case7_rr.result new file mode 100644 index 00000000000..dbcb0a03aef --- /dev/null +++ b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case7_rr.result @@ -0,0 +1,41 @@ + +----------------------------------------------------------------------- +- Locking issues case 7: +- Rows that are scanned as part of a query but not in the table being +- updated should not be locked unless rocksdb_lock_scanned_rows is on +----------------------------------------------------------------------- +DROP TABLE IF EXISTS t1, t2; +SELECT @@global.rocksdb_lock_scanned_rows; +@@global.rocksdb_lock_scanned_rows +0 +CREATE TABLE t1(id INT PRIMARY KEY, value INT); +CREATE TABLE t2(id INT PRIMARY KEY, value INT); +INSERT INTO t1 VALUES (1,1), (2,2), (3,3); +INSERT INTO t2 VALUES (1,1), (2,2), (3,3), (4,4), (5,5); +connect con1,localhost,root,,; +connect con2,localhost,root,,; +connection con1; +SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; +BEGIN; +connection con2; +SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; +BEGIN; +lock_scanned_rows is 0 +connection con1; +UPDATE t1 JOIN t2 ON t1.id = t2.id SET t1.value=t1.value+100 WHERE t2.id=3; +connection con2; +UPDATE t2 SET value=value+100; +SELECT * FROM t2; +id value +1 101 +2 102 +3 103 +4 104 +5 105 +connection con1; +COMMIT; +connection default; +disconnect con1; +disconnect con2; +DROP TABLE t1; +DROP TABLE t2; diff --git a/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case7_rr_lsr.result b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case7_rr_lsr.result new file mode 100644 index 00000000000..d9f7e333d3c --- /dev/null +++ b/storage/rocksdb/mysql-test/rocksdb/r/locking_issues_case7_rr_lsr.result @@ -0,0 +1,45 @@ + +----------------------------------------------------------------------- +- Locking issues case 7: +- Rows that are scanned as part of a query but not in the table being +- updated should not be locked unless rocksdb_lock_scanned_rows is on +----------------------------------------------------------------------- +DROP TABLE IF EXISTS t1, t2; +SELECT @@global.rocksdb_lock_scanned_rows; +@@global.rocksdb_lock_scanned_rows +0 +SET GLOBAL rocksdb_lock_scanned_rows=ON; +CREATE TABLE t1(id INT PRIMARY KEY, value INT); +CREATE TABLE t2(id INT PRIMARY KEY, value INT); +INSERT INTO t1 VALUES (1,1), (2,2), (3,3); +INSERT INTO t2 VALUES (1,1), (2,2), (3,3), (4,4), (5,5); +connect con1,localhost,root,,; +connect con2,localhost,root,,; +connection con1; +SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; +BEGIN; +connection con2; +SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; +BEGIN; +lock_scanned_rows is 1 +connection con1; +UPDATE t1 JOIN t2 ON t1.id = t2.id SET t1.value=t1.value+100 WHERE t2.id=3; +connection con2; +UPDATE t2 SET value=value+100 WHERE id=3; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +UPDATE t2 SET value=value+100 WHERE id IN (1,2,4,5); +SELECT * FROM t2; +id value +1 101 +2 102 +3 3 +4 104 +5 105 +connection con1; +COMMIT; +connection default; +disconnect con1; +disconnect con2; +DROP TABLE t1; +DROP TABLE t2; +SET GLOBAL rocksdb_lock_scanned_rows=0; diff --git a/storage/rocksdb/mysql-test/rocksdb/t/locking_issues.test b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues.test index 18a796573d1..41e2f69578a 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/locking_issues.test +++ b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues.test @@ -1,67 +1,3 @@ --source include/have_rocksdb.inc -let $isolation_level = REPEATABLE READ; ---source include/locking_issues_case1_1.inc - -let $isolation_level = READ COMMITTED; ---source include/locking_issues_case1_1.inc - -let $isolation_level = REPEATABLE READ; ---source include/locking_issues_case1_2.inc - -let $isolation_level = READ COMMITTED; ---source include/locking_issues_case1_2.inc - -let $lock_scanned_rows=0; -let $isolation_level = REPEATABLE READ; ---source include/locking_issues_case2.inc - -let $isolation_level = READ COMMITTED; ---source include/locking_issues_case2.inc - -# Rerun the case2 tests with rocksdb_lock_scanned_rows on -let $lock_scanned_rows=1; -let $isolation_level = REPEATABLE READ; ---source include/locking_issues_case2.inc - -let $isolation_level = READ COMMITTED; ---source include/locking_issues_case2.inc - -let $isolation_level = REPEATABLE READ; ---source include/locking_issues_case3.inc - -let $isolation_level = READ COMMITTED; ---source include/locking_issues_case3.inc - -let $isolation_level = REPEATABLE READ; ---source include/locking_issues_case4.inc - -let $isolation_level = READ COMMITTED; ---source include/locking_issues_case4.inc - -let $isolation_level = REPEATABLE READ; ---source include/locking_issues_case5.inc - -let $isolation_level = READ COMMITTED; ---source include/locking_issues_case5.inc - -let $isolation_level = REPEATABLE READ; ---source include/locking_issues_case6.inc - -let $isolation_level = READ COMMITTED; ---source include/locking_issues_case6.inc - -let $lock_scanned_rows=0; -let $isolation_level = REPEATABLE READ; ---source include/locking_issues_case7.inc - -let $isolation_level = READ COMMITTED; ---source include/locking_issues_case7.inc - -# Rerun the case7 tests with rocksdb_lock_scanned_rows on -let $lock_scanned_rows=1; -let $isolation_level = REPEATABLE READ; ---source include/locking_issues_case7.inc - -let $isolation_level = READ COMMITTED; ---source include/locking_issues_case7.inc +--echo tests moved to rocksdb.locking_issues_case* diff --git a/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case1_1_rc.test b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case1_1_rc.test new file mode 100644 index 00000000000..3fd183bf4dd --- /dev/null +++ b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case1_1_rc.test @@ -0,0 +1,4 @@ +--source include/have_rocksdb.inc + +let $isolation_level = READ COMMITTED; +--source include/locking_issues_case1_1.inc diff --git a/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case1_1_rr.test b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case1_1_rr.test new file mode 100644 index 00000000000..cd4a0bd3c9d --- /dev/null +++ b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case1_1_rr.test @@ -0,0 +1,4 @@ +--source include/have_rocksdb.inc + +let $isolation_level = REPEATABLE READ; +--source include/locking_issues_case1_1.inc diff --git a/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case1_2_rc.test b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case1_2_rc.test new file mode 100644 index 00000000000..3fe052a4099 --- /dev/null +++ b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case1_2_rc.test @@ -0,0 +1,4 @@ +--source include/have_rocksdb.inc + +let $isolation_level = READ COMMITTED; +--source include/locking_issues_case1_2.inc diff --git a/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case1_2_rr.test b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case1_2_rr.test new file mode 100644 index 00000000000..02263273ba5 --- /dev/null +++ b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case1_2_rr.test @@ -0,0 +1,4 @@ +--source include/have_rocksdb.inc + +let $isolation_level = REPEATABLE READ; +--source include/locking_issues_case1_2.inc diff --git a/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case2_rc.test b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case2_rc.test new file mode 100644 index 00000000000..d780b5247bc --- /dev/null +++ b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case2_rc.test @@ -0,0 +1,5 @@ +--source include/have_rocksdb.inc + +let $lock_scanned_rows=0; +let $isolation_level = READ COMMITTED; +--source include/locking_issues_case2.inc diff --git a/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case2_rc_lsr.test b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case2_rc_lsr.test new file mode 100644 index 00000000000..bd46f93a76c --- /dev/null +++ b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case2_rc_lsr.test @@ -0,0 +1,5 @@ +--source include/have_rocksdb.inc + +let $lock_scanned_rows=1; +let $isolation_level = READ COMMITTED; +--source include/locking_issues_case2.inc diff --git a/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case2_rr.test b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case2_rr.test new file mode 100644 index 00000000000..b820fddb979 --- /dev/null +++ b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case2_rr.test @@ -0,0 +1,5 @@ +--source include/have_rocksdb.inc + +let $lock_scanned_rows=0; +let $isolation_level = REPEATABLE READ; +--source include/locking_issues_case2.inc diff --git a/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case2_rr_lsr.test b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case2_rr_lsr.test new file mode 100644 index 00000000000..33d3b752098 --- /dev/null +++ b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case2_rr_lsr.test @@ -0,0 +1,5 @@ +--source include/have_rocksdb.inc + +let $lock_scanned_rows=1; +let $isolation_level = REPEATABLE READ; +--source include/locking_issues_case2.inc diff --git a/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case3_rc.test b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case3_rc.test new file mode 100644 index 00000000000..7dc7f8784ea --- /dev/null +++ b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case3_rc.test @@ -0,0 +1,4 @@ +--source include/have_rocksdb.inc + +let $isolation_level = READ COMMITTED; +--source include/locking_issues_case3.inc diff --git a/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case3_rr.test b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case3_rr.test new file mode 100644 index 00000000000..7c81daccebc --- /dev/null +++ b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case3_rr.test @@ -0,0 +1,4 @@ +--source include/have_rocksdb.inc + +let $isolation_level = REPEATABLE READ; +--source include/locking_issues_case3.inc diff --git a/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case4_rc.test b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case4_rc.test new file mode 100644 index 00000000000..edc1111b0a5 --- /dev/null +++ b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case4_rc.test @@ -0,0 +1,4 @@ +--source include/have_rocksdb.inc + +let $isolation_level = READ COMMITTED; +--source include/locking_issues_case4.inc diff --git a/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case4_rr.test b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case4_rr.test new file mode 100644 index 00000000000..8c26c2d1e19 --- /dev/null +++ b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case4_rr.test @@ -0,0 +1,4 @@ +--source include/have_rocksdb.inc + +let $isolation_level = REPEATABLE READ; +--source include/locking_issues_case4.inc diff --git a/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case5_rc.test b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case5_rc.test new file mode 100644 index 00000000000..10bedcf2cca --- /dev/null +++ b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case5_rc.test @@ -0,0 +1,4 @@ +--source include/have_rocksdb.inc + +let $isolation_level = READ COMMITTED; +--source include/locking_issues_case5.inc diff --git a/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case5_rr.test b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case5_rr.test new file mode 100644 index 00000000000..6de3847cb66 --- /dev/null +++ b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case5_rr.test @@ -0,0 +1,4 @@ +--source include/have_rocksdb.inc + +let $isolation_level = REPEATABLE READ; +--source include/locking_issues_case5.inc diff --git a/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case6_rc.test b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case6_rc.test new file mode 100644 index 00000000000..9409bde0c58 --- /dev/null +++ b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case6_rc.test @@ -0,0 +1,4 @@ +--source include/have_rocksdb.inc + +let $isolation_level = READ COMMITTED; +--source include/locking_issues_case6.inc diff --git a/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case6_rr.test b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case6_rr.test new file mode 100644 index 00000000000..0c7a8a116c3 --- /dev/null +++ b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case6_rr.test @@ -0,0 +1,4 @@ +--source include/have_rocksdb.inc + +let $isolation_level = REPEATABLE READ; +--source include/locking_issues_case6.inc diff --git a/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case7_rc.test b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case7_rc.test new file mode 100644 index 00000000000..f8e874a135c --- /dev/null +++ b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case7_rc.test @@ -0,0 +1,5 @@ +--source include/have_rocksdb.inc + +let $lock_scanned_rows=0; +let $isolation_level = READ COMMITTED; +--source include/locking_issues_case7.inc diff --git a/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case7_rc_lsr.test b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case7_rc_lsr.test new file mode 100644 index 00000000000..0f97ca2f00f --- /dev/null +++ b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case7_rc_lsr.test @@ -0,0 +1,5 @@ +--source include/have_rocksdb.inc + +let $lock_scanned_rows=1; +let $isolation_level = READ COMMITTED; +--source include/locking_issues_case7.inc diff --git a/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case7_rr.test b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case7_rr.test new file mode 100644 index 00000000000..c8cec956893 --- /dev/null +++ b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case7_rr.test @@ -0,0 +1,5 @@ +--source include/have_rocksdb.inc + +let $lock_scanned_rows=0; +let $isolation_level = REPEATABLE READ; +--source include/locking_issues_case7.inc diff --git a/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case7_rr_lsr.test b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case7_rr_lsr.test new file mode 100644 index 00000000000..875e81a1e05 --- /dev/null +++ b/storage/rocksdb/mysql-test/rocksdb/t/locking_issues_case7_rr_lsr.test @@ -0,0 +1,5 @@ +--source include/have_rocksdb.inc + +let $lock_scanned_rows=1; +let $isolation_level = REPEATABLE READ; +--source include/locking_issues_case7.inc |