summaryrefslogtreecommitdiff
path: root/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_locks.test
diff options
context:
space:
mode:
authorSergei Petrunia <psergey@askmonty.org>2016-10-06 17:24:09 +0000
committerSergei Petrunia <psergey@askmonty.org>2016-10-06 17:24:09 +0000
commitebfc4e6ad02b0cef34ec3f446007b98d85af9296 (patch)
tree1811d0c75aaf4aa3f130d3f35a86c769dcfadce4 /storage/rocksdb/mysql-test/rocksdb/t/rocksdb_locks.test
downloadmariadb-git-ebfc4e6ad02b0cef34ec3f446007b98d85af9296.tar.gz
Initial commit,
copy of commit 86587affafe77ef555f7c3839839de44f0f203f3 Author: Tian Xia <tianx@fb.com> Date: Tue Oct 4 10:01:52 2016 -0700 Allow filtering of show commands through admission control
Diffstat (limited to 'storage/rocksdb/mysql-test/rocksdb/t/rocksdb_locks.test')
-rw-r--r--storage/rocksdb/mysql-test/rocksdb/t/rocksdb_locks.test92
1 files changed, 92 insertions, 0 deletions
diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_locks.test b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_locks.test
new file mode 100644
index 00000000000..3b28df0d63b
--- /dev/null
+++ b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_locks.test
@@ -0,0 +1,92 @@
+--source include/have_rocksdb.inc
+
+#
+# MyRocks-specific tests for locking
+#
+--source include/have_debug.inc
+
+--enable_connect_log
+create table t1 (pk int not null primary key) engine=rocksdb;
+
+insert into t1 values (1),(2),(3);
+
+set autocommit=0;
+begin;
+select * from t1 where pk=1 for update;
+
+--connect (con1,localhost,root,,)
+--connection con1
+--echo ### Connection con1
+let $ID= `select connection_id()`;
+set @@rocksdb_lock_wait_timeout=500;
+set autocommit=0;
+begin;
+--send select * from t1 where pk=1 for update;
+
+--connection default
+--echo ### Connection default
+
+let $wait_condition= select 1 from INFORMATION_SCHEMA.PROCESSLIST
+ where ID = $ID and STATE = "Waiting for row lock";
+--source include/wait_condition.inc
+## Waiting for row lock
+## select connection_id();
+## select state='Waiting for row lock' from information_schema.processlist where id=2;
+
+rollback;
+
+connection con1;
+reap;
+rollback;
+connection default;
+
+##
+## Now, repeat the same test but let the wait time out.
+##
+begin;
+select * from t1 where pk=1 for update;
+
+--connection con1
+--echo ### Connection con1
+set @@rocksdb_lock_wait_timeout=2;
+set autocommit=0;
+begin;
+--error ER_LOCK_WAIT_TIMEOUT
+select * from t1 where pk=1 for update;
+
+--connection default
+
+rollback;
+set autocommit=1;
+
+--connection con1
+drop table t1;
+--connection default
+
+--echo #
+--echo # Now, test what happens if another transaction modified the record and committed
+--echo #
+
+CREATE TABLE t1 (
+ id int primary key,
+ value int
+) engine=rocksdb collate latin1_bin;
+insert into t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9),(10,10);
+
+--connection con1
+BEGIN;
+SELECT * FROM t1 WHERE id=3;
+
+--connection default
+BEGIN;
+UPDATE t1 SET value=30 WHERE id=3;
+COMMIT;
+
+--connection con1
+--error ER_LOCK_DEADLOCK
+SELECT * FROM t1 WHERE id=3 FOR UPDATE;
+
+ROLLBACK;
+--disconnect con1
+--connection default
+drop table t1;