[Commits] 670bbd25c: Range Locking: make GetLockStatusData report locks in STO mode
revision-id: 670bbd25c10c47638f41ee7f635a99443d21e937 (v5.8-1896-g670bbd25c) parent(s): c15474bf496a227c6247e2e56040009c55c4bbc0 author: Sergei Petrunia committer: Sergei Petrunia timestamp: 2019-11-24 18:26:26 +0300 message: Range Locking: make GetLockStatusData report locks in STO mode (Implement this in locktree:dump_locks) Before this patch, GetLockStatusData would return empty list when the lock tree is in STO (Single Transaction Optimization mode. This is confusing. Note: some MTR testcases have workarounds for this: they get a lock in another connection to make sure we're not in STO-mode. They will still have to do that, because STO-mode may report different set of locks (e.g. the locks can overlap with one another). --- .../range_locking/locktree/locktree.cc | 44 +++++++++++++++------- 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/utilities/transactions/range_locking/locktree/locktree.cc b/utilities/transactions/range_locking/locktree/locktree.cc index 00ce5aace..4c7ce1bfe 100644 --- a/utilities/transactions/range_locking/locktree/locktree.cc +++ b/utilities/transactions/range_locking/locktree/locktree.cc @@ -543,22 +543,38 @@ void locktree::dump_locks(void *cdata, dump_callback cb) lkr.prepare(m_rangetree); lkr.acquire(range); - GrowableArray<row_lock> all_locks; - all_locks.init(); - iterate_and_get_overlapping_row_locks(&lkr, &all_locks); - - const size_t n_locks = all_locks.get_size(); - for (size_t i = 0; i < n_locks; i++) { - const row_lock lock = all_locks.fetch_unchecked(i); - (*cb)(cdata, - lock.range.get_left_key(), - lock.range.get_right_key(), - lock.txnid, - lock.is_shared, - lock.owners); + TXNID sto_txn; + if ((sto_txn = toku_unsafe_fetch(m_sto_txnid)) != TXNID_NONE) { + // insert all of the ranges from the single txnid buffer into a new rangtree + range_buffer::iterator iter(&m_sto_buffer); + range_buffer::iterator::record rec; + while (iter.current(&rec)) { + (*cb)(cdata, + rec.get_left_key(), + rec.get_right_key(), + sto_txn, + !rec.get_exclusive_flag(), + nullptr); + iter.next(); + } + } else { + GrowableArray<row_lock> all_locks; + all_locks.init(); + iterate_and_get_overlapping_row_locks(&lkr, &all_locks); + + const size_t n_locks = all_locks.get_size(); + for (size_t i = 0; i < n_locks; i++) { + const row_lock lock = all_locks.fetch_unchecked(i); + (*cb)(cdata, + lock.range.get_left_key(), + lock.range.get_right_key(), + lock.txnid, + lock.is_shared, + lock.owners); + } + all_locks.deinit(); } lkr.release(); - all_locks.deinit(); range.destroy(); }
participants (1)
-
psergey