Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/mysql-test/suite/rocksdb/r/select_for_update.result b/mysql-test/suite/rocksdb/r/select_for_update.result
- index 713f5e8..d416c37 100644
- --- a/mysql-test/suite/rocksdb/r/select_for_update.result
- +++ b/mysql-test/suite/rocksdb/r/select_for_update.result
- @@ -33,3 +33,48 @@ a b
- 2 b
- 3 c
- DROP TABLE t1;
- +#######################################################################
- +# Test unlock_row in MyRocks
- +#
- +create table t1 (
- +pk int primary key,
- +col1 int
- +) engine=rocksdb;
- +insert into t1 values
- +(1, 1),
- +(2, 2),
- +(3, 3);
- +connect con1,localhost,root,,;
- +## Test if SELECT FOR UPDATE releases locks for rows that didn't match WHERE
- +connection con1;
- +begin;
- +select * from t1 where col1 > 2 for update;
- +pk col1
- +3 3
- +connection default;
- +begin;
- +select * from t1 where pk=2 for update;
- +pk col1
- +2 2
- +select * from t1 where pk=3 for update;
- +ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on index: test.t1.PRIMARY
- +rollback;
- +connection con1;
- +rollback;
- +## Test if UPDATE also releases locks
- +begin;
- +update t1 set col1=col1+100 where col1!=1;
- +connection default;
- +begin;
- +update t1 set col1=col1+500 where pk=1;
- +commit;
- +connection con1;
- +commit;
- +select * from t1;
- +pk col1
- +1 501
- +2 102
- +3 103
- +connection default;
- +disconnect con1;
- +drop table t1;
- diff --git a/mysql-test/suite/rocksdb/t/select_for_update.test b/mysql-test/suite/rocksdb/t/select_for_update.test
- index 14fdfb7..2fc4d39 100644
- --- a/mysql-test/suite/rocksdb/t/select_for_update.test
- +++ b/mysql-test/suite/rocksdb/t/select_for_update.test
- @@ -51,5 +51,59 @@ SELECT a,b FROM t1;
- DROP TABLE t1;
- +--echo #######################################################################
- +--echo # Test unlock_row in MyRocks
- +--echo #
- +create table t1 (
- + pk int primary key,
- + col1 int
- +) engine=rocksdb;
- +
- +insert into t1 values
- +(1, 1),
- +(2, 2),
- +(3, 3);
- +
- +--connect (con1,localhost,root,,)
- +
- +--echo ## Test if SELECT FOR UPDATE releases locks for rows that didn't match WHERE
- +--connection con1
- +begin;
- +select * from t1 where col1 > 2 for update;
- +
- +--connection default
- +begin;
- +## The following should disappear:
- +## --error ER_LOCK_WAIT_TIMEOUT
- +select * from t1 where pk=2 for update;
- +--error ER_LOCK_WAIT_TIMEOUT
- +select * from t1 where pk=3 for update;
- +rollback;
- +
- +--connection con1
- +rollback;
- +
- +--echo ## Test if UPDATE also releases locks
- +begin;
- +update t1 set col1=col1+100 where col1!=1;
- +
- +--connection default
- +begin;
- +##
- +## Note: if one puts "WHERE col1=1" in the next query, it will fail with
- +## an error, because other trx is holding locks on rows with pk IN (1,2).
- +## Does it make sense to switch to late locking to handle this case?
- +##
- +update t1 set col1=col1+500 where pk=1;
- +commit;
- +
- +--connection con1
- +commit;
- +
- +select * from t1;
- +--connection default
- +--disconnect con1
- +drop table t1;
- +
- --source include/wait_until_count_sessions.inc
- diff --git a/rocksdb b/rocksdb
- index 3b2a1dd..8e6172b 160000
- --- a/rocksdb
- +++ b/rocksdb
- @@ -1 +1 @@
- -Subproject commit 3b2a1ddd2e9ca0998aa711644258675324febf6a
- +Subproject commit 8e6172bc5771272d99f85a72ff7cd1ef3df668e5-dirty
- diff --git a/storage/rocksdb/ha_rocksdb.cc b/storage/rocksdb/ha_rocksdb.cc
- index 5137734..d078490 100644
- --- a/storage/rocksdb/ha_rocksdb.cc
- +++ b/storage/rocksdb/ha_rocksdb.cc
- @@ -1381,10 +1381,7 @@ public:
- void release_lock(rocksdb::ColumnFamilyHandle* column_family,
- const std::string &rowkey)
- {
- - /*
- - TODO: Need RocksDB's transaction API implement this call:
- - txn->UnLock(column_family->GetID(), rowkey);
- - */
- + txn->UndoGetForUpdate(column_family, rowkey);
- }
- bool commit_or_rollback()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement