revision-id: c5930c1671e366aff227657b0c622c31f05c7d63 (fb-prod8-202009-61-gc5930c1671e) parent(s): 7fb5516c55a1c8bc79785aa592ae335e973d7182 author: Sergei Petrunia committer: Sergei Petrunia timestamp: 2021-02-01 23:07:00 +0300 message: Code cleanup and fix tests - rocksdb.issue243_transactionStatus-range_locking - rocksdb.range_locking_refresh_iter (release build) --- ...issue243_transactionStatus-range_locking.result | 33 +++++++++++++++++++++- .../rocksdb/t/range_locking_refresh_iter.test | 1 + storage/rocksdb/CMakeLists.txt | 1 - storage/rocksdb/ha_rocksdb.cc | 6 ++-- 4 files changed, 37 insertions(+), 4 deletions(-) diff --git a/mysql-test/suite/rocksdb/r/issue243_transactionStatus-range_locking.result b/mysql-test/suite/rocksdb/r/issue243_transactionStatus-range_locking.result index 28bbcb48c96..b48535c5ee6 100644 --- a/mysql-test/suite/rocksdb/r/issue243_transactionStatus-range_locking.result +++ b/mysql-test/suite/rocksdb/r/issue243_transactionStatus-range_locking.result @@ -60,7 +60,7 @@ LIST OF SNAPSHOTS FOR EACH SESSION: ---SNAPSHOT, ACTIVE NUM sec MySQL thread id TID, OS thread handle PTR, query id QID localhost root ACTION SHOW ENGINE rocksdb TRANSACTION STATUS -lock count 8, write count 4 +lock count 4, write count 4 insert count 2, update count 1, delete count 1 ----------LATEST DETECTED DEADLOCKS---------- ----------------------------------------- @@ -149,3 +149,34 @@ END OF ROCKSDB TRANSACTION MONITOR OUTPUT ROLLBACK; SET AUTOCOMMIT=1; DROP TABLE t2; +DROP TABLE IF EXISTS t2; +CREATE TABLE t2 ( +id1 INT, +id2 INT, +value INT, +PRIMARY KEY (id1), +UNIQUE KEY (id2) +) ENGINE=rocksdb; +SET AUTOCOMMIT=0; +START TRANSACTION; +INSERT INTO t2 VALUES(1,2,0),(10,20,30); +UPDATE t2 SET value=3 WHERE id2=2; +DELETE FROM t2 WHERE id1=10; +SHOW ENGINE rocksdb TRANSACTION STATUS; +Type Name Status +rocksdb +============================================================ +TIMESTAMP ROCKSDB TRANSACTION MONITOR OUTPUT +============================================================ +--------- +SNAPSHOTS +--------- +LIST OF SNAPSHOTS FOR EACH SESSION: +----------LATEST DETECTED DEADLOCKS---------- +----------------------------------------- +END OF ROCKSDB TRANSACTION MONITOR OUTPUT +========================================= + +ROLLBACK; +SET AUTOCOMMIT=1; +DROP TABLE t2; diff --git a/mysql-test/suite/rocksdb/t/range_locking_refresh_iter.test b/mysql-test/suite/rocksdb/t/range_locking_refresh_iter.test index a9e3de29aac..4cf8b02576c 100644 --- a/mysql-test/suite/rocksdb/t/range_locking_refresh_iter.test +++ b/mysql-test/suite/rocksdb/t/range_locking_refresh_iter.test @@ -1,5 +1,6 @@ --source include/have_rocksdb.inc --source suite/rocksdb/include/have_range_locking.inc +--source include/have_debug_sync.inc select @@rocksdb_use_range_locking; diff --git a/storage/rocksdb/CMakeLists.txt b/storage/rocksdb/CMakeLists.txt index cfa584d9f2b..2d733044c33 100644 --- a/storage/rocksdb/CMakeLists.txt +++ b/storage/rocksdb/CMakeLists.txt @@ -55,7 +55,6 @@ INCLUDE_DIRECTORIES( ${ROCKSDB_ROOT} ${ROCKSDB_ROOT}/include ${ROCKSDB_ROOT}/third-party/gtest-1.8.1/fused-src - ${CMAKE_SOURCE_DIR}/rocksdb/utilities/transactions/lock/range/range_tree/ ) # Suppress warnings for all compilers diff --git a/storage/rocksdb/ha_rocksdb.cc b/storage/rocksdb/ha_rocksdb.cc index 13376b57814..92f96c464f8 100644 --- a/storage/rocksdb/ha_rocksdb.cc +++ b/storage/rocksdb/ha_rocksdb.cc @@ -3146,7 +3146,9 @@ class Rdb_transaction { virtual void acquire_snapshot(bool acquire_now) = 0; virtual void release_snapshot() = 0; - bool has_snapshot() const { return m_read_opts.snapshot != nullptr; } + bool has_snapshot() const { + return m_read_opts.snapshot != nullptr || m_saved_snapshot; + } private: // The Rdb_sst_info structures we are currently loading. In a partitioned @@ -5095,7 +5097,7 @@ class Rdb_snapshot_status : public Rdb_tx_list_walker { /* Calculate the duration the snapshot has existed */ int64_t snapshot_timestamp = tx->m_snapshot_timestamp; - if (snapshot_timestamp != 0) { + if (snapshot_timestamp != 0 && tx->has_snapshot()) { int64_t curr_time; rdb->GetEnv()->GetCurrentTime(&curr_time);