[Commits] 902585ed8: Code cleanup: correct argument to KillLockWait

Sergei Petrunia psergey at askmonty.org
Fri Jan 25 19:47:23 EET 2019


revision-id: 902585ed89b86b26e8e1ef8b055c268fd1c0e8ca (v5.8-1028-g902585ed8)
parent(s): e836be43ec6c2bd9250764e09b51766b11b04390
author: Sergei Petrunia
committer: Sergei Petrunia
timestamp: 2019-01-25 20:47:23 +0300
message:

Code cleanup: correct argument to KillLockWait

---
 include/rocksdb/utilities/transaction_db.h          |  2 +-
 utilities/transactions/pessimistic_transaction_db.h |  4 ++--
 utilities/transactions/transaction_lock_mgr.cc      | 14 ++++++++++----
 utilities/transactions/transaction_lock_mgr.h       |  2 +-
 4 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/include/rocksdb/utilities/transaction_db.h b/include/rocksdb/utilities/transaction_db.h
index aa68a6243..2eb46a211 100644
--- a/include/rocksdb/utilities/transaction_db.h
+++ b/include/rocksdb/utilities/transaction_db.h
@@ -289,7 +289,7 @@ class TransactionDB : public StackableDB {
   bool use_range_locking;
   virtual RangeLockMgrControl* get_range_lock_manager() { return nullptr; }
 
-  virtual void KillLockWait(void *cdata){};
+  virtual void KillLockWait(TransactionID txnid){};
  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.h b/utilities/transactions/pessimistic_transaction_db.h
index 1be4143c1..07ed3fed2 100644
--- a/utilities/transactions/pessimistic_transaction_db.h
+++ b/utilities/transactions/pessimistic_transaction_db.h
@@ -127,9 +127,9 @@ class PessimisticTransactionDB : public TransactionDB {
   virtual void UpdateCFComparatorMap(const std::vector<ColumnFamilyHandle*>&) {}
   virtual void UpdateCFComparatorMap(ColumnFamilyHandle*) {}
 
-  void KillLockWait(void *cdata) override {
+  void KillLockWait(TransactionID txnid) override {
     if (use_range_locking)
-      range_lock_mgr_.KillLockWait(cdata);
+      range_lock_mgr_.KillLockWait(txnid);
   }
  protected:
   DBImpl* db_impl_;
diff --git a/utilities/transactions/transaction_lock_mgr.cc b/utilities/transactions/transaction_lock_mgr.cc
index cd9da2986..62092948f 100644
--- a/utilities/transactions/transaction_lock_mgr.cc
+++ b/utilities/transactions/transaction_lock_mgr.cc
@@ -791,8 +791,8 @@ public:
 };
 
 
-void RangeLockMgr::KillLockWait(void *cdata) {
-  ltm.kill_waiter(cdata);
+void RangeLockMgr::KillLockWait(TransactionID txnid) {
+  ltm.kill_waiter((void*)txnid);
 }
 
 // Get a range lock on [start_key; end_key] range
@@ -807,8 +807,14 @@ Status RangeLockMgr::TryRangeLock(PessimisticTransaction* txn,
 
   toku_fill_dbt(&start_key_dbt, start_key.data(), start_key.size());
   toku_fill_dbt(&end_key_dbt, end_key.data(), end_key.size());
-  request.set(lt, (TXNID)txn, &start_key_dbt, &end_key_dbt, toku::lock_request::WRITE,
-              false /* not a big txn */, (void*)txn->GetID()/*client_extra, for KILL*/);
+
+  // Use the txnid as "extra" in the lock_request. Then, KillLockWait()
+  // will be able to use kill_waiter(txn_id) to kill the wait if needed
+  TransactionID wait_txn_id = txn->GetID();
+
+  request.set(lt, (TXNID)txn, &start_key_dbt, &end_key_dbt,
+              toku::lock_request::WRITE, false /* not a big txn */,
+              (void*)wait_txn_id);
   
   uint64_t killed_time_msec = 0; // TODO: what should this have?
   uint64_t wait_time_msec = txn->GetLockTimeout();
diff --git a/utilities/transactions/transaction_lock_mgr.h b/utilities/transactions/transaction_lock_mgr.h
index f2380aad7..e16ce8501 100644
--- a/utilities/transactions/transaction_lock_mgr.h
+++ b/utilities/transactions/transaction_lock_mgr.h
@@ -217,7 +217,7 @@ class RangeLockMgr :
 
   RangeLockMgr(TransactionDB* txn_db);
 
-  void KillLockWait(void *cdata);
+  void KillLockWait(TransactionID txnid);
 
   int set_max_lock_memory(size_t max_lock_memory) override
   {


More information about the commits mailing list