[Commits] 6c2479afa92: MDEV-21314: Range Locking: individual rows are locked when scanning PK
revision-id: 6c2479afa9280fc5ac6d7f904a9a8dca284c6f5b (fb-prod201903-274-g6c2479afa92) parent(s): 33a3184a56e03cec2a910ed3b7c67624e08ab993 author: Sergei Petrunia committer: Sergei Petrunia timestamp: 2020-01-06 18:55:43 +0300 message: MDEV-21314: Range Locking: individual rows are locked when scanning PK Remove redundant locking in several places: - RocksDB's Put and [Single]Delete should not acquire locks when Range Lock manager is used. - MyRocks should not re-read rows with GetForUpdate() if range locking is used. Exception to this is the slave thread: it doesn't do range locking when searching for rows to update. Because of that, it will keep the old behavior and call GetForUpdate. --- mysql-test/suite/rocksdb/r/range_locking.result | 5 +---- mysql-test/suite/rocksdb/r/range_locking_escalation.result | 2 +- mysql-test/suite/rocksdb/r/range_locking_rev_cf.result | 5 +---- mysql-test/suite/rocksdb/t/range_locking.inc | 2 +- rocksdb | 2 +- storage/rocksdb/ha_rocksdb.cc | 8 +++++--- 6 files changed, 10 insertions(+), 14 deletions(-) diff --git a/mysql-test/suite/rocksdb/r/range_locking.result b/mysql-test/suite/rocksdb/r/range_locking.result index 3205045c3b3..3641fb1943e 100644 --- a/mysql-test/suite/rocksdb/r/range_locking.result +++ b/mysql-test/suite/rocksdb/r/range_locking.result @@ -108,13 +108,12 @@ $cf_id $trx_id 00${indexnr}80000019 - 01${indexnr}80000028 X rollback; begin; # The following will show a range lock on 2-9 and also a point lock on 10. -# This is how things currently work. +# This is how things currently work. (after MDEV-21314, not anymore) select * from t1 where pk between 2 and 9 for update; pk a # select * from information_schema.rocksdb_locks; # With replacements by select_from_is_rowlocks.inc COLUMN_FAMILY_ID TRANSACTION_ID KEY mode $cf_id $trx_id 00${indexnr}80000002 - 01${indexnr}80000009 X -$cf_id $trx_id 00${indexnr}8000000a X rollback; drop table t1; connection con1; @@ -437,7 +436,6 @@ pk1 pk2 a 3 0 30 # select * from information_schema.rocksdb_locks; # With replacements by select_from_is_rowlocks.inc COLUMN_FAMILY_ID TRANSACTION_ID KEY mode -$cf_id $trx_id 00${indexnr}8000000280000009 X $cf_id $trx_id 00${indexnr}80000003 - 01${indexnr}80000003 X rollback; # @@ -463,7 +461,6 @@ pk1 pk2 a 4 5 45 # select * from information_schema.rocksdb_locks; # With replacements by select_from_is_rowlocks.inc COLUMN_FAMILY_ID TRANSACTION_ID KEY mode -$cf_id $trx_id 00${indexnr}8000000480000004 X $cf_id $trx_id 00${indexnr}8000000480000005 - 01${indexnr}8000000480000008 X rollback; connection con1; diff --git a/mysql-test/suite/rocksdb/r/range_locking_escalation.result b/mysql-test/suite/rocksdb/r/range_locking_escalation.result index 7b94df0c092..ae4c01cad72 100644 --- a/mysql-test/suite/rocksdb/r/range_locking_escalation.result +++ b/mysql-test/suite/rocksdb/r/range_locking_escalation.result @@ -23,5 +23,5 @@ count(*) 10000 show status like 'rocksdb_locktree_escalation_count'; Variable_name Value -rocksdb_locktree_escalation_count 3328 +rocksdb_locktree_escalation_count 3321 drop table t0,t1; diff --git a/mysql-test/suite/rocksdb/r/range_locking_rev_cf.result b/mysql-test/suite/rocksdb/r/range_locking_rev_cf.result index c10ebf6bf87..d33d4872fab 100644 --- a/mysql-test/suite/rocksdb/r/range_locking_rev_cf.result +++ b/mysql-test/suite/rocksdb/r/range_locking_rev_cf.result @@ -108,13 +108,12 @@ $cf_id $trx_id 00${indexnr}80000028 - 01${indexnr}80000019 X rollback; begin; # The following will show a range lock on 2-9 and also a point lock on 10. -# This is how things currently work. +# This is how things currently work. (after MDEV-21314, not anymore) select * from t1 where pk between 2 and 9 for update; pk a # select * from information_schema.rocksdb_locks; # With replacements by select_from_is_rowlocks.inc COLUMN_FAMILY_ID TRANSACTION_ID KEY mode $cf_id $trx_id 00${indexnr}80000009 - 01${indexnr}80000002 X -$cf_id $trx_id 00${indexnr}8000000a X rollback; drop table t1; connection con1; @@ -397,7 +396,6 @@ pk1 pk2 a 3 0 30 # select * from information_schema.rocksdb_locks; # With replacements by select_from_is_rowlocks.inc COLUMN_FAMILY_ID TRANSACTION_ID KEY mode -$cf_id $trx_id 00${indexnr}8000000280000009 X $cf_id $trx_id 00${indexnr}80000003 - 01${indexnr}80000003 X rollback; # @@ -423,7 +421,6 @@ pk1 pk2 a 4 5 45 # select * from information_schema.rocksdb_locks; # With replacements by select_from_is_rowlocks.inc COLUMN_FAMILY_ID TRANSACTION_ID KEY mode -$cf_id $trx_id 00${indexnr}8000000480000004 X $cf_id $trx_id 00${indexnr}8000000480000008 - 01${indexnr}8000000480000005 X rollback; connection con1; diff --git a/mysql-test/suite/rocksdb/t/range_locking.inc b/mysql-test/suite/rocksdb/t/range_locking.inc index fd0f3f4e6c6..c676ccb66db 100644 --- a/mysql-test/suite/rocksdb/t/range_locking.inc +++ b/mysql-test/suite/rocksdb/t/range_locking.inc @@ -132,7 +132,7 @@ delete from t1 where pk between 25 and 40; rollback; begin; --echo # The following will show a range lock on 2-9 and also a point lock on 10. ---echo # This is how things currently work. +--echo # This is how things currently work. (after MDEV-21314, not anymore) select * from t1 where pk between 2 and 9 for update; --source suite/rocksdb/include/select_from_is_rowlocks.inc rollback; diff --git a/rocksdb b/rocksdb index 1c9d747b0e4..6b3b684f69a 160000 --- a/rocksdb +++ b/rocksdb @@ -1 +1 @@ -Subproject commit 1c9d747b0e426df3dff4bc70f1ff7ba0271621b0 +Subproject commit 6b3b684f69a5b6ad968f2270e54e92de1a42d468 diff --git a/storage/rocksdb/ha_rocksdb.cc b/storage/rocksdb/ha_rocksdb.cc index b00801c62ab..44ab3ef36df 100644 --- a/storage/rocksdb/ha_rocksdb.cc +++ b/storage/rocksdb/ha_rocksdb.cc @@ -8187,7 +8187,7 @@ int ha_rocksdb::read_row_from_primary_key(uchar *const buf) { memcpy(m_pk_packed_tuple, pk_data, pk_size); m_last_rowkey.copy(pk_data, pk_size, &my_charset_bin); - if (m_lock_rows != RDB_LOCK_NONE) { + if (m_lock_rows != RDB_LOCK_NONE && !rocksdb_use_range_locking) { /* We need to put a lock and re-read */ rc = get_row_by_rowid(buf, m_pk_packed_tuple, pk_size); } else { @@ -10796,7 +10796,8 @@ void ha_rocksdb::setup_iterator_for_rnd_scan() { rocksdb::Slice table_key((const char *)m_pk_packed_tuple, key_size); setup_scan_iterator(*m_pk_descr, &table_key, false, key_start_matching_bytes, - (m_lock_rows != RDB_LOCK_NONE) && rocksdb_use_range_locking); + (m_lock_rows != RDB_LOCK_NONE) && + rocksdb_use_range_locking && !ha_thd()->rli_slave); m_scan_it->Seek(table_key); m_skip_scan_it_next_call = true; } @@ -10918,7 +10919,8 @@ int ha_rocksdb::rnd_next_with_direction(uchar *const buf, bool move_forward) { break; } - if (m_lock_rows != RDB_LOCK_NONE) { + if (m_lock_rows != RDB_LOCK_NONE && (!rocksdb_use_range_locking || + ha_thd()->rli_slave)) { /* Lock the row we've just read.
participants (1)
-
psergey