[Commits] 33a3184a56e: Range Locking: previous cset cont'd: fix assertions with reverse-order CFs
revision-id: 33a3184a56e03cec2a910ed3b7c67624e08ab993 (fb-prod201903-273-g33a3184a56e) parent(s): f9cc0d345aeccabcb84ac98ce5d1130b637e024d author: Sergei Petrunia committer: Sergei Petrunia timestamp: 2020-01-05 18:04:51 +0300 message: Range Locking: previous cset cont'd: fix assertions with reverse-order CFs - Endpoint flags must be flipped whenever we are using reverse-ordered CFs. - As for range endpoints themselves = they must be flipped when doing a reverse-ordered scan = they must NOT be flipped when using reverse-ordered CF. (but the code in index_first/index_last already "flips" them by calling index_(first|last)_intern. Take all of the above into account. --- mysql-test/suite/rocksdb/r/range_locking.result | 2 +- .../suite/rocksdb/r/range_locking_rev_cf.result | 2 +- storage/rocksdb/ha_rocksdb.cc | 23 +++++++++++++++------- storage/rocksdb/ha_rocksdb.h | 1 + 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/mysql-test/suite/rocksdb/r/range_locking.result b/mysql-test/suite/rocksdb/r/range_locking.result index 85264fbf2fa..3205045c3b3 100644 --- a/mysql-test/suite/rocksdb/r/range_locking.result +++ b/mysql-test/suite/rocksdb/r/range_locking.result @@ -510,7 +510,7 @@ pk a 1992 1992 # 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}800007c6 - 01${indexnr+1} X +$cf_id $trx_id 00${indexnr}800007c6 - 00${indexnr+1} X rollback; connection con1; rollback; 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 87522d5ae37..c10ebf6bf87 100644 --- a/mysql-test/suite/rocksdb/r/range_locking_rev_cf.result +++ b/mysql-test/suite/rocksdb/r/range_locking_rev_cf.result @@ -470,7 +470,7 @@ pk a 1992 1992 # 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}800007c6 - 01${indexnr+1} X +$cf_id $trx_id 00${indexnr}800007c6 - 00${indexnr+1} X rollback; connection con1; rollback; diff --git a/storage/rocksdb/ha_rocksdb.cc b/storage/rocksdb/ha_rocksdb.cc index f77da1bc8da..b00801c62ab 100644 --- a/storage/rocksdb/ha_rocksdb.cc +++ b/storage/rocksdb/ha_rocksdb.cc @@ -8393,6 +8393,7 @@ int ha_rocksdb::read_range_first(const key_range *const start_key, if (!start_key) { // Read first record + // (range locking will set the lock inside the ha_index_first call) result = ha_index_first(table->record[0]); } else { if (is_using_prohibited_gap_locks( @@ -8443,6 +8444,7 @@ int ha_rocksdb::set_range_lock(Rdb_transaction *tx, const enum ha_rkey_function &find_flag, const rocksdb::Slice &slice_arg, const key_range *const end_key, + bool flip_rev_cf, bool *use_locking_iterator ) { @@ -8591,12 +8593,19 @@ int ha_rocksdb::set_range_lock(Rdb_transaction *tx, no_end_endpoint= true; } + if (kd.m_is_reverse_cf) { + // Flip the endpoint flags + end_has_inf_suffix = !end_has_inf_suffix; + start_has_inf_suffix = !start_has_inf_suffix; + } + rocksdb::Endpoint start_endp; rocksdb::Endpoint end_endp; - if (kd.m_is_reverse_cf) { + + if (flip_rev_cf && kd.m_is_reverse_cf) { // Flip the endpoints - start_endp =rocksdb::Endpoint(end_slice, !end_has_inf_suffix); - end_endp = rocksdb::Endpoint(slice, !start_has_inf_suffix); + start_endp =rocksdb::Endpoint(end_slice, end_has_inf_suffix); + end_endp = rocksdb::Endpoint(slice, start_has_inf_suffix); } else { start_endp= rocksdb::Endpoint(slice, start_has_inf_suffix); end_endp= rocksdb::Endpoint(end_slice, end_has_inf_suffix); @@ -8747,7 +8756,7 @@ int ha_rocksdb::index_read_map_impl(uchar *const buf, const uchar *const key, bool use_locking_iterator; rocksdb::Slice lock_slice(reinterpret_cast<const char *>(m_sk_packed_tuple), packed_size); - if ((rc = set_range_lock(tx, kd, find_flag, lock_slice, end_key, + if ((rc = set_range_lock(tx, kd, find_flag, lock_slice, end_key, true, &use_locking_iterator))) DBUG_RETURN(rc); @@ -9432,7 +9441,7 @@ int ha_rocksdb::index_first_intern(uchar *const buf) { bool use_locking_iter; if ((rc = set_range_lock(tx, kd, HA_READ_KEY_OR_NEXT, index_key, - end_range, &use_locking_iter))) + end_range, false, &use_locking_iter))) DBUG_RETURN(rc); const bool is_new_snapshot = !tx->has_snapshot(); @@ -9527,8 +9536,8 @@ int ha_rocksdb::index_last_intern(uchar *const buf) { DBUG_ASSERT(tx != nullptr); bool use_locking_iter; - if ((rc = set_range_lock(tx, kd, HA_READ_PREFIX_LAST_OR_PREV, index_key, - end_range, &use_locking_iter))) + if ((rc = set_range_lock(tx, kd, HA_READ_BEFORE_KEY, index_key, + end_range, false, &use_locking_iter))) DBUG_RETURN(rc); bool is_new_snapshot = !tx->has_snapshot(); diff --git a/storage/rocksdb/ha_rocksdb.h b/storage/rocksdb/ha_rocksdb.h index 272dc9973d4..cbe894df8f5 100644 --- a/storage/rocksdb/ha_rocksdb.h +++ b/storage/rocksdb/ha_rocksdb.h @@ -329,6 +329,7 @@ class ha_rocksdb : public my_core::handler { const enum ha_rkey_function &find_flag, const rocksdb::Slice &slice, const key_range *const end_key, + bool flip_rev_cf, bool *use_locking_iterator); void release_scan_iterator(void);
participants (1)
-
Sergei Petrunia