[Commits] d629f93: Getting tests to pass with range locking
revision-id: d629f934d907f506bd114d9d48852e6570d333da parent(s): 2fa28d505b745ffbac9235e4b8f235202bc75b69 committer: Sergei Petrunia branch nick: modules timestamp: 2018-09-24 17:45:11 +0300 message: Getting tests to pass with range locking - Set lock wait timeout correctly - Make waits KILL-able with KILL command --- include/rocksdb/utilities/transaction_db.h | 2 ++ utilities/transactions/pessimistic_transaction_db.cc | 1 - utilities/transactions/pessimistic_transaction_db.h | 5 +++++ utilities/transactions/transaction_lock_mgr.cc | 18 +++++++++++++----- utilities/transactions/transaction_lock_mgr.h | 2 ++ 5 files changed, 22 insertions(+), 6 deletions(-) diff --git a/include/rocksdb/utilities/transaction_db.h b/include/rocksdb/utilities/transaction_db.h index 1cf205e..415544e 100644 --- a/include/rocksdb/utilities/transaction_db.h +++ b/include/rocksdb/utilities/transaction_db.h @@ -259,6 +259,8 @@ class TransactionDB : public StackableDB { // psergey-TODO: move this elsewhere. bool use_range_locking; + + virtual void KillLockWait(void *cdata){}; protected: // To Create an TransactionDB, call Open() // The ownership of db is transferred to the base StackableDB diff --git a/utilities/transactions/pessimistic_transaction_db.cc b/utilities/transactions/pessimistic_transaction_db.cc index 0c8428b..dcc420a 100644 --- a/utilities/transactions/pessimistic_transaction_db.cc +++ b/utilities/transactions/pessimistic_transaction_db.cc @@ -373,7 +373,6 @@ Status PessimisticTransactionDB::TryLock(PessimisticTransaction* txn, uint32_t cfh_id, const std::string& key, bool exclusive) { - //fprintf(stderr, "AAA: PessimisticTransactionDB::TryLock calling extra lock\n"); if (use_range_locking) return range_lock_mgr_.TryLock(txn, cfh_id, key, GetEnv(), exclusive); else diff --git a/utilities/transactions/pessimistic_transaction_db.h b/utilities/transactions/pessimistic_transaction_db.h index 17becf1..1876de5 100644 --- a/utilities/transactions/pessimistic_transaction_db.h +++ b/utilities/transactions/pessimistic_transaction_db.h @@ -122,6 +122,11 @@ class PessimisticTransactionDB : public TransactionDB { virtual void UpdateCFComparatorMap(const std::vector<ColumnFamilyHandle*>&) {} virtual void UpdateCFComparatorMap(ColumnFamilyHandle*) {} + void KillLockWait(void *cdata) override + { + if (use_range_locking) + range_lock_mgr_.KillLockWait(cdata); + } protected: DBImpl* db_impl_; std::shared_ptr<Logger> info_log_; diff --git a/utilities/transactions/transaction_lock_mgr.cc b/utilities/transactions/transaction_lock_mgr.cc index 476b9fc..0ce5124 100644 --- a/utilities/transactions/transaction_lock_mgr.cc +++ b/utilities/transactions/transaction_lock_mgr.cc @@ -315,6 +315,10 @@ Status TransactionLockMgr::TryLock(PessimisticTransaction* txn, timeout, lock_info); } +void RangeLockMgr::KillLockWait(void *cdata) +{ + ltm.kill_waiter(cdata); +} // psergey: new code: // (TODO: the below ignores column_family_id !) @@ -328,10 +332,14 @@ Status RangeLockMgr::TryLock(PessimisticTransaction* txn, toku_fill_dbt(&key_dbt, key.data(), key.size()); request.set(lt, txn->GetID(), &key_dbt, &key_dbt, toku::lock_request::WRITE, - false /* not a big txn */, nullptr /*client_extra*/); + false /* not a big txn */, (void*)txn->GetID() /*client_extra*/); - const uint64_t wait_time_msec=1000*1000*1000; - const uint64_t killed_time_msec=1000*1000*1000; + uint64_t killed_time_msec = 0; // TODO: what should this have? + uint64_t wait_time_msec = txn->GetLockTimeout(); + // convert microseconds to milliseconds + if (wait_time_msec != (uint64_t)-1) + wait_time_msec = (wait_time_msec + 500) / 1000; + request.start(); const int r = request.wait(wait_time_msec, killed_time_msec, nullptr, /* killed_callback */ @@ -700,7 +708,7 @@ another_lock_mgr_release_lock_int(toku::locktree *lt, void RangeLockMgr::UnLock(PessimisticTransaction* txn, uint32_t column_family_id, const std::string& key, Env* env) { - fprintf(stderr, "RangeLockMgr::UnLock (key)\n"); + //fprintf(stderr, "RangeLockMgr::UnLock (key)\n"); another_lock_mgr_release_lock_int(lt, txn, column_family_id, key); toku::lock_request::retry_all_lock_requests(lt, nullptr /* lock_wait_needed_callback */); } @@ -708,7 +716,7 @@ void RangeLockMgr::UnLock(PessimisticTransaction* txn, void RangeLockMgr::UnLock(const PessimisticTransaction* txn, const TransactionKeyMap* key_map, Env* env) { - fprintf(stderr, "RangeLockMgr::UnLock(key_map)\n"); + //fprintf(stderr, "RangeLockMgr::UnLock(key_map)\n"); for (auto& key_map_iter : *key_map) { diff --git a/utilities/transactions/transaction_lock_mgr.h b/utilities/transactions/transaction_lock_mgr.h index c6ef954..3580441 100644 --- a/utilities/transactions/transaction_lock_mgr.h +++ b/utilities/transactions/transaction_lock_mgr.h @@ -105,6 +105,8 @@ class RangeLockMgr :public BaseLockMgr { } + void KillLockWait(void *cdata); + private: toku::locktree_manager ltm; toku::locktree *lt; // only one tree for now
participants (1)
-
psergey@askmonty.org