Advertisement
Guest User

Untitled

a guest
Feb 11th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.59 KB | None | 0 0
  1. diff --git a/mysql-test/suite/rocksdb/r/select_for_update.result b/mysql-test/suite/rocksdb/r/select_for_update.result
  2. index 713f5e8..d416c37 100644
  3. --- a/mysql-test/suite/rocksdb/r/select_for_update.result
  4. +++ b/mysql-test/suite/rocksdb/r/select_for_update.result
  5. @@ -33,3 +33,48 @@ a b
  6. 2 b
  7. 3 c
  8. DROP TABLE t1;
  9. +#######################################################################
  10. +# Test unlock_row in MyRocks
  11. +#
  12. +create table t1 (
  13. +pk int primary key,
  14. +col1 int
  15. +) engine=rocksdb;
  16. +insert into t1 values
  17. +(1, 1),
  18. +(2, 2),
  19. +(3, 3);
  20. +connect con1,localhost,root,,;
  21. +## Test if SELECT FOR UPDATE releases locks for rows that didn't match WHERE
  22. +connection con1;
  23. +begin;
  24. +select * from t1 where col1 > 2 for update;
  25. +pk col1
  26. +3 3
  27. +connection default;
  28. +begin;
  29. +select * from t1 where pk=2 for update;
  30. +pk col1
  31. +2 2
  32. +select * from t1 where pk=3 for update;
  33. +ERROR HY000: Lock wait timeout exceeded; try restarting transaction: Timeout on index: test.t1.PRIMARY
  34. +rollback;
  35. +connection con1;
  36. +rollback;
  37. +## Test if UPDATE also releases locks
  38. +begin;
  39. +update t1 set col1=col1+100 where col1!=1;
  40. +connection default;
  41. +begin;
  42. +update t1 set col1=col1+500 where pk=1;
  43. +commit;
  44. +connection con1;
  45. +commit;
  46. +select * from t1;
  47. +pk col1
  48. +1 501
  49. +2 102
  50. +3 103
  51. +connection default;
  52. +disconnect con1;
  53. +drop table t1;
  54. diff --git a/mysql-test/suite/rocksdb/t/select_for_update.test b/mysql-test/suite/rocksdb/t/select_for_update.test
  55. index 14fdfb7..2fc4d39 100644
  56. --- a/mysql-test/suite/rocksdb/t/select_for_update.test
  57. +++ b/mysql-test/suite/rocksdb/t/select_for_update.test
  58. @@ -51,5 +51,59 @@ SELECT a,b FROM t1;
  59.  
  60. DROP TABLE t1;
  61.  
  62. +--echo #######################################################################
  63. +--echo # Test unlock_row in MyRocks
  64. +--echo #
  65. +create table t1 (
  66. + pk int primary key,
  67. + col1 int
  68. +) engine=rocksdb;
  69. +
  70. +insert into t1 values
  71. +(1, 1),
  72. +(2, 2),
  73. +(3, 3);
  74. +
  75. +--connect (con1,localhost,root,,)
  76. +
  77. +--echo ## Test if SELECT FOR UPDATE releases locks for rows that didn't match WHERE
  78. +--connection con1
  79. +begin;
  80. +select * from t1 where col1 > 2 for update;
  81. +
  82. +--connection default
  83. +begin;
  84. +## The following should disappear:
  85. +## --error ER_LOCK_WAIT_TIMEOUT
  86. +select * from t1 where pk=2 for update;
  87. +--error ER_LOCK_WAIT_TIMEOUT
  88. +select * from t1 where pk=3 for update;
  89. +rollback;
  90. +
  91. +--connection con1
  92. +rollback;
  93. +
  94. +--echo ## Test if UPDATE also releases locks
  95. +begin;
  96. +update t1 set col1=col1+100 where col1!=1;
  97. +
  98. +--connection default
  99. +begin;
  100. +##
  101. +## Note: if one puts "WHERE col1=1" in the next query, it will fail with
  102. +## an error, because other trx is holding locks on rows with pk IN (1,2).
  103. +## Does it make sense to switch to late locking to handle this case?
  104. +##
  105. +update t1 set col1=col1+500 where pk=1;
  106. +commit;
  107. +
  108. +--connection con1
  109. +commit;
  110. +
  111. +select * from t1;
  112. +--connection default
  113. +--disconnect con1
  114. +drop table t1;
  115. +
  116. --source include/wait_until_count_sessions.inc
  117.  
  118. diff --git a/rocksdb b/rocksdb
  119. index 3b2a1dd..8e6172b 160000
  120. --- a/rocksdb
  121. +++ b/rocksdb
  122. @@ -1 +1 @@
  123. -Subproject commit 3b2a1ddd2e9ca0998aa711644258675324febf6a
  124. +Subproject commit 8e6172bc5771272d99f85a72ff7cd1ef3df668e5-dirty
  125. diff --git a/storage/rocksdb/ha_rocksdb.cc b/storage/rocksdb/ha_rocksdb.cc
  126. index 5137734..d078490 100644
  127. --- a/storage/rocksdb/ha_rocksdb.cc
  128. +++ b/storage/rocksdb/ha_rocksdb.cc
  129. @@ -1381,10 +1381,7 @@ public:
  130. void release_lock(rocksdb::ColumnFamilyHandle* column_family,
  131. const std::string &rowkey)
  132. {
  133. - /*
  134. - TODO: Need RocksDB's transaction API implement this call:
  135. - txn->UnLock(column_family->GetID(), rowkey);
  136. - */
  137. + txn->UndoGetForUpdate(column_family, rowkey);
  138. }
  139.  
  140. bool commit_or_rollback()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement