[Commits] 3b3b49b0049: Count the obtained range locks in Rdb_transaction::m_lock_count
revision-id: 3b3b49b00496de0807646583d47425b7718fcaa6 (fb-prod201903-275-g3b3b49b0049) parent(s): 6c2479afa9280fc5ac6d7f904a9a8dca284c6f5b author: Sergei Petrunia committer: Sergei Petrunia timestamp: 2020-01-06 22:37:43 +0300 message: Count the obtained range locks in Rdb_transaction::m_lock_count This fixes rocksdb.trx_info'range_locking' test. --- storage/rocksdb/ha_rocksdb.cc | 4 +++- storage/rocksdb/rdb_locking_iter.cc | 6 ++++-- storage/rocksdb/rdb_locking_iter.h | 11 ++++++++--- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/storage/rocksdb/ha_rocksdb.cc b/storage/rocksdb/ha_rocksdb.cc index 44ab3ef36df..c2fbaa25293 100644 --- a/storage/rocksdb/ha_rocksdb.cc +++ b/storage/rocksdb/ha_rocksdb.cc @@ -3378,6 +3378,7 @@ class Rdb_transaction_impl : public Rdb_transaction { rocksdb::Status lock_range(rocksdb::ColumnFamilyHandle *const cf, const rocksdb::Endpoint &start_endp, const rocksdb::Endpoint &end_endp) override { + ++m_lock_count; return m_rocksdb_tx->GetRangeLock(cf, start_endp, end_endp); } private: @@ -3622,7 +3623,8 @@ class Rdb_transaction_impl : public Rdb_transaction { global_stats.queries[QUERIES_RANGE].inc(); if (use_locking_iterator) { locking_iter_created(); - return GetLockingIterator(m_rocksdb_tx, options, column_family, is_rev_cf); + return GetLockingIterator(m_rocksdb_tx, options, column_family, + is_rev_cf, &m_lock_count); } else return m_rocksdb_tx->GetIterator(options, column_family); diff --git a/storage/rocksdb/rdb_locking_iter.cc b/storage/rocksdb/rdb_locking_iter.cc index 7f5e241d906..983d98639aa 100644 --- a/storage/rocksdb/rdb_locking_iter.cc +++ b/storage/rocksdb/rdb_locking_iter.cc @@ -12,8 +12,10 @@ rocksdb::Iterator* GetLockingIterator( rocksdb::Transaction *trx, const rocksdb::ReadOptions& read_options, rocksdb::ColumnFamilyHandle* column_family, - bool is_rev_cf) { - return new LockingIterator(trx, column_family, is_rev_cf, read_options); + bool is_rev_cf, + ulonglong *counter) { + return new LockingIterator(trx, column_family, is_rev_cf, read_options, + counter); } /* diff --git a/storage/rocksdb/rdb_locking_iter.h b/storage/rocksdb/rdb_locking_iter.h index 855f3f2cc0a..e77e5b77913 100644 --- a/storage/rocksdb/rdb_locking_iter.h +++ b/storage/rocksdb/rdb_locking_iter.h @@ -42,14 +42,17 @@ class LockingIterator : public rocksdb::Iterator { // note: an iterator that has reached EOF has status()==OK && valid_==false bool valid_; + ulonglong *lock_count_; public: LockingIterator(rocksdb::Transaction *txn, rocksdb::ColumnFamilyHandle *cfh, bool is_rev_cf, - const rocksdb::ReadOptions& opts + const rocksdb::ReadOptions& opts, + ulonglong *lock_count=nullptr ) : txn_(txn), cfh_(cfh), m_is_rev_cf(is_rev_cf), read_opts_(opts), iter_(nullptr), - status_(rocksdb::Status::InvalidArgument()), valid_(false) {} + status_(rocksdb::Status::InvalidArgument()), valid_(false), + lock_count_(lock_count) {} ~LockingIterator() { delete iter_; @@ -117,6 +120,7 @@ class LockingIterator : public rocksdb::Iterator { valid_ = false; return; } + if (lock_count_) (*lock_count_)++; std::string end_key_copy= end_key.ToString(); //Ok, now we have a lock which is inhibiting modifications in the range @@ -179,6 +183,7 @@ rocksdb::Iterator* GetLockingIterator(rocksdb::Transaction *trx, const rocksdb::ReadOptions& read_options, rocksdb::ColumnFamilyHandle* column_family, - bool is_rev_cf); + bool is_rev_cf, + ulonglong *counter); } // namespace myrocks
participants (1)
-
psergey