revision-id: 926762540d9873042d0a1d2afc5fc2c456260908 parent(s): aaa8e2bf45cdebcbbb10fb33e87503a2f4064c33 committer: Sergei Petrunia branch nick: mysql-5.6-rocksdb-rangelocking2 timestamp: 2018-10-08 19:35:19 +0300 message: Make RangeLockMgr::UnLock() only unlock the keys that it is asked to unlock. The MyRocks part. --- rocksdb | 2 +- storage/rocksdb/range_locking/locktree/locktree.cc | 32 ++++++++++++++++++++-- storage/rocksdb/range_locking/locktree/locktree.h | 2 +- 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/rocksdb b/rocksdb index d629f93..b2be543 160000 --- a/rocksdb +++ b/rocksdb @@ -1 +1 @@ -Subproject commit d629f934d907f506bd114d9d48852e6570d333da +Subproject commit b2be543c0d6084c1bd5ff99d6ffed90ff3d0bd24 diff --git a/storage/rocksdb/range_locking/locktree/locktree.cc b/storage/rocksdb/range_locking/locktree/locktree.cc index 069aae2..75f7830 100644 --- a/storage/rocksdb/range_locking/locktree/locktree.cc +++ b/storage/rocksdb/range_locking/locktree/locktree.cc @@ -521,12 +521,40 @@ bool locktree::sto_try_release(TXNID txnid) { return released; } + // release all of the locks for a txnid whose endpoints are pairs // in the given range buffer. -void locktree::release_locks(TXNID txnid, const range_buffer *ranges) { +void locktree::release_locks(TXNID txnid, const range_buffer *ranges, + bool all_trx_locks_hint) { // try the single txn optimization. if it worked, then all of the // locks are already released, otherwise we need to do it here. - bool released = sto_try_release(txnid); + bool released; + if (all_trx_locks_hint) + { + // This will release all of the locks the transaction is holding + released = sto_try_release(txnid); + } + else + { + /* + psergey: we are asked to release *Some* of the locks the transaction + is holding. + We could try doing that without leaving the STO mode, but right now, + the easiest way is to exit the STO mode and let the non-STO code path + handle it. + */ + if (toku_unsafe_fetch(m_sto_txnid) != TXNID_NONE) { + // check the bit again with a prepared locked keyrange, + // which protects the optimization bits and rangetree data + concurrent_tree::locked_keyrange lkr; + lkr.prepare(m_rangetree); + if (m_sto_txnid != TXNID_NONE) { + sto_end_early(&lkr); + } + lkr.release(); + } + released = false; + } if (!released) { range_buffer::iterator iter(ranges); range_buffer::iterator::record rec; diff --git a/storage/rocksdb/range_locking/locktree/locktree.h b/storage/rocksdb/range_locking/locktree/locktree.h index bb3ea9d..0e6b5d6 100644 --- a/storage/rocksdb/range_locking/locktree/locktree.h +++ b/storage/rocksdb/range_locking/locktree/locktree.h @@ -296,7 +296,7 @@ namespace toku { const DBT *left_key, const DBT *right_key, txnid_set *conflicts); // effect: Release all of the lock ranges represented by the range buffer for a txnid. - void release_locks(TXNID txnid, const range_buffer *ranges); + void release_locks(TXNID txnid, const range_buffer *ranges, bool all_trx_locks_hint= false); // effect: Runs escalation on this locktree void escalate(lt_escalate_cb after_escalate_callback, void *extra);