Commit 34b66fcc authored by Sergei Petrunia's avatar Sergei Petrunia

MariaRocks port: get rocksdb.locking_issues test to work

Also update test results (MariaDB's dialect changes)
parent 7b708ee3
......@@ -8636,6 +8636,19 @@ int ha_rocksdb::update_row(const uchar *old_data, uchar *new_data)
}
/*
MariaDB's temporary: MyRocks has this function in sql/handler.cc:
*/
bool can_hold_read_locks_on_select(THD *thd, thr_lock_type lock_type)
{
return (lock_type == TL_READ_WITH_SHARED_LOCKS
|| lock_type == TL_READ_NO_INSERT
|| (lock_type != TL_IGNORE
&& thd->lex->sql_command != SQLCOM_SELECT));
}
/* The following function was copied from ha_blackhole::store_lock: */
THR_LOCK_DATA **ha_rocksdb::store_lock(THD *thd,
THR_LOCK_DATA **to,
......@@ -8668,11 +8681,7 @@ THR_LOCK_DATA **ha_rocksdb::store_lock(THD *thd,
uint sql_command = my_core::thd_sql_command(thd);
if ((lock_type == TL_READ && in_lock_tables) ||
(lock_type == TL_READ_HIGH_PRIORITY && in_lock_tables) ||
#ifdef MARIAROCKS_NOT_YET
can_hold_read_locks_on_select(thd, lock_type))
#else
false)
#endif
{
ulong tx_isolation = my_core::thd_tx_isolation(thd);
if (sql_command != SQLCOM_CHECKSUM &&
......
......@@ -8,17 +8,25 @@
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: Timeout on index: test.t0.PRIMARY
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: Timeout on index: test.t0.PRIMARY
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
connection con1;
COMMIT;
connection default;
disconnect con1;
disconnect con2;
DROP TABLE t0;
-----------------------------------------------------------------------
......@@ -30,17 +38,25 @@ DROP TABLE t0;
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: Timeout on index: test.t0.PRIMARY
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: Timeout on index: test.t0.PRIMARY
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
connection con1;
COMMIT;
connection default;
disconnect con1;
disconnect con2;
DROP TABLE t0;
-----------------------------------------------------------------------
......@@ -52,17 +68,25 @@ DROP TABLE t0;
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;
-----------------------------------------------------------------------
......@@ -74,17 +98,25 @@ DROP TABLE t0;
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;
-----------------------------------------------------------------------
......@@ -99,18 +131,26 @@ SELECT @@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: Timeout on index: test.t0.PRIMARY
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
......@@ -122,7 +162,11 @@ id value
3 0
4 0
5 1
connection con1;
COMMIT;
connection default;
disconnect con1;
disconnect con2;
DROP TABLE t0;
-----------------------------------------------------------------------
......@@ -137,18 +181,26 @@ SELECT @@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: Timeout on index: test.t0.PRIMARY
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
......@@ -160,7 +212,11 @@ id value
3 0
4 0
5 1
connection con1;
COMMIT;
connection default;
disconnect con1;
disconnect con2;
DROP TABLE t0;
-----------------------------------------------------------------------
......@@ -176,17 +232,27 @@ SELECT @@global.rocksdb_lock_scanned_rows;
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: Timeout on index: test.t0.PRIMARY
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;
......@@ -203,17 +269,27 @@ SELECT @@global.rocksdb_lock_scanned_rows;
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: Timeout on index: test.t0.PRIMARY
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;
......@@ -225,11 +301,19 @@ SET GLOBAL rocksdb_lock_scanned_rows=0;
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 40001: Deadlock found when trying to get lock; try restarting transaction
connection default;
disconnect con1;
disconnect con2;
DROP TABLE t0;
-----------------------------------------------------------------------
......@@ -240,11 +324,19 @@ DROP TABLE t0;
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;
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
connection default;
disconnect con1;
disconnect con2;
DROP TABLE t0;
-----------------------------------------------------------------------
......@@ -255,11 +347,19 @@ DROP TABLE t0;
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;
-----------------------------------------------------------------------
......@@ -270,11 +370,19 @@ DROP TABLE t0;
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;
-----------------------------------------------------------------------
......@@ -286,15 +394,23 @@ 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 40001: Deadlock found when trying to get lock; try restarting transaction
COMMIT;
connection default;
disconnect con1;
disconnect con2;
DROP TABLE t0;
-----------------------------------------------------------------------
......@@ -306,15 +422,23 @@ 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;
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
COMMIT;
connection default;
disconnect con1;
disconnect con2;
DROP TABLE t0;
-----------------------------------------------------------------------
......@@ -326,15 +450,23 @@ 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 40001: Deadlock found when trying to get lock; try restarting transaction
COMMIT;
connection default;
disconnect con1;
disconnect con2;
DROP TABLE t0;
-----------------------------------------------------------------------
......@@ -346,15 +478,23 @@ 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;
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
COMMIT;
connection default;
disconnect con1;
disconnect con2;
DROP TABLE t0;
-----------------------------------------------------------------------
......@@ -370,12 +510,18 @@ 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
......@@ -384,7 +530,11 @@ id value
3 103
4 104
5 105
connection con1;
COMMIT;
connection default;
disconnect con1;
disconnect con2;
DROP TABLE t1;
DROP TABLE t2;
......@@ -401,12 +551,18 @@ 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
......@@ -415,7 +571,11 @@ id value
3 103
4 104
5 105
connection con1;
COMMIT;
connection default;
disconnect con1;
disconnect con2;
DROP TABLE t1;
DROP TABLE t2;
......@@ -433,14 +593,20 @@ 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: Timeout on index: test.t2.PRIMARY
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
......@@ -449,7 +615,11 @@ id value
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;
......@@ -468,14 +638,20 @@ 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: Timeout on index: test.t2.PRIMARY
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
......@@ -484,7 +660,11 @@ id value
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;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment