Commit d87531a6 authored by Marko Mäkelä's avatar Marko Mäkelä

Follow-up to MDEV-14952: Remove some more btr_get_search_latch()

Replace some !rw_lock_own() assertions with the stronger
!btr_search_own_any(). Remove some redundant btr_get_search_latch()
calls.

btr_search_update_hash_ref(): Remove a duplicated assertion.

btr_search_build_page_hash_index(): Remove a duplicated assertion.
rw_lock_s_lock() asserts that the latch is not being held.

btr_search_disable_ref_count(): Remove an assertion. The only caller
is acquiring all adaptive hash index latches.
parent 2281fcf3
...@@ -189,13 +189,13 @@ will not guarantee success. ...@@ -189,13 +189,13 @@ will not guarantee success.
@param[in] index index handler */ @param[in] index index handler */
static static
void void
btr_search_check_free_space_in_heap(dict_index_t* index) btr_search_check_free_space_in_heap(const dict_index_t* index)
{ {
hash_table_t* table; hash_table_t* table;
mem_heap_t* heap; mem_heap_t* heap;
ut_ad(!rw_lock_own(btr_get_search_latch(index), RW_LOCK_S)); ut_ad(!btr_search_own_any(RW_LOCK_S));
ut_ad(!rw_lock_own(btr_get_search_latch(index), RW_LOCK_X)); ut_ad(!btr_search_own_any(RW_LOCK_X));
table = btr_get_search_table(index); table = btr_get_search_table(index);
...@@ -345,9 +345,6 @@ btr_search_disable_ref_count( ...@@ -345,9 +345,6 @@ btr_search_disable_ref_count(
for (index = dict_table_get_first_index(table); for (index = dict_table_get_first_index(table);
index != NULL; index != NULL;
index = dict_table_get_next_index(index)) { index = dict_table_get_next_index(index)) {
ut_ad(rw_lock_own(btr_get_search_latch(index), RW_LOCK_X));
index->search_info->ref_count = 0; index->search_info->ref_count = 0;
} }
} }
...@@ -464,8 +461,8 @@ btr_search_info_update_hash( ...@@ -464,8 +461,8 @@ btr_search_info_update_hash(
ulint n_unique; ulint n_unique;
int cmp; int cmp;
ut_ad(!rw_lock_own(btr_get_search_latch(index), RW_LOCK_S)); ut_ad(!btr_search_own_any(RW_LOCK_S));
ut_ad(!rw_lock_own(btr_get_search_latch(index), RW_LOCK_X)); ut_ad(!btr_search_own_any(RW_LOCK_X));
if (dict_index_is_ibuf(index)) { if (dict_index_is_ibuf(index)) {
/* So many deletes are performed on an insert buffer tree /* So many deletes are performed on an insert buffer tree
...@@ -572,14 +569,14 @@ semaphore, to save CPU time! Do not assume the fields are consistent. ...@@ -572,14 +569,14 @@ semaphore, to save CPU time! Do not assume the fields are consistent.
@param[in,out] block buffer block @param[in,out] block buffer block
@param[in] cursor cursor */ @param[in] cursor cursor */
static static
ibool bool
btr_search_update_block_hash_info( btr_search_update_block_hash_info(
btr_search_t* info, btr_search_t* info,
buf_block_t* block, buf_block_t* block,
const btr_cur_t* cursor) const btr_cur_t* cursor)
{ {
ut_ad(!rw_lock_own(btr_get_search_latch(cursor->index), RW_LOCK_S)); ut_ad(!btr_search_own_any(RW_LOCK_S));
ut_ad(!rw_lock_own(btr_get_search_latch(cursor->index), RW_LOCK_X)); ut_ad(!btr_search_own_any(RW_LOCK_X));
ut_ad(rw_lock_own(&block->lock, RW_LOCK_S) ut_ad(rw_lock_own(&block->lock, RW_LOCK_S)
|| rw_lock_own(&block->lock, RW_LOCK_X)); || rw_lock_own(&block->lock, RW_LOCK_X));
...@@ -626,11 +623,11 @@ btr_search_update_block_hash_info( ...@@ -626,11 +623,11 @@ btr_search_update_block_hash_info(
/* Build a new hash index on the page */ /* Build a new hash index on the page */
return(TRUE); return(true);
} }
} }
return(FALSE); return(false);
} }
/** Updates a hash node reference when it has been unsuccessfully used in a /** Updates a hash node reference when it has been unsuccessfully used in a
...@@ -670,8 +667,8 @@ btr_search_update_hash_ref( ...@@ -670,8 +667,8 @@ btr_search_update_hash_ref(
} }
ut_ad(block->page.id.space() == index->space); ut_ad(block->page.id.space() == index->space);
ut_a(index == cursor->index); ut_ad(index == cursor->index);
ut_a(!dict_index_is_ibuf(index)); ut_ad(!dict_index_is_ibuf(index));
if ((info->n_hash_potential > 0) if ((info->n_hash_potential > 0)
&& (block->curr_n_fields == info->n_fields) && (block->curr_n_fields == info->n_fields)
...@@ -696,7 +693,6 @@ btr_search_update_hash_ref( ...@@ -696,7 +693,6 @@ btr_search_update_hash_ref(
if (UNIV_LIKELY_NULL(heap)) { if (UNIV_LIKELY_NULL(heap)) {
mem_heap_free(heap); mem_heap_free(heap);
} }
ut_ad(rw_lock_own(btr_get_search_latch(index), RW_LOCK_X));
ha_insert_for_fold(btr_get_search_table(index), fold, ha_insert_for_fold(btr_get_search_table(index), fold,
block, rec); block, rec);
...@@ -948,10 +944,9 @@ btr_search_guess_on_hash( ...@@ -948,10 +944,9 @@ btr_search_guess_on_hash(
} }
} else { } else {
ut_ad(btr_search_enabled); ut_ad(btr_search_enabled);
ut_ad(rw_lock_own(ahi_latch, RW_LOCK_S));
} }
ut_ad(rw_lock_own(btr_get_search_latch(index), RW_LOCK_S));
rec = (rec_t*) ha_search_and_get_data( rec = (rec_t*) ha_search_and_get_data(
btr_get_search_table(index), fold); btr_get_search_table(index), fold);
...@@ -1379,7 +1374,6 @@ btr_search_build_page_hash_index( ...@@ -1379,7 +1374,6 @@ btr_search_build_page_hash_index(
ut_a(!dict_index_is_ibuf(index)); ut_a(!dict_index_is_ibuf(index));
ut_ad(page_is_leaf(block->frame)); ut_ad(page_is_leaf(block->frame));
ut_ad(!rw_lock_own(btr_get_search_latch(index), RW_LOCK_X));
ut_ad(rw_lock_own(&(block->lock), RW_LOCK_S) ut_ad(rw_lock_own(&(block->lock), RW_LOCK_S)
|| rw_lock_own(&(block->lock), RW_LOCK_X)); || rw_lock_own(&(block->lock), RW_LOCK_X));
......
...@@ -61,8 +61,8 @@ btr_search_info_update( ...@@ -61,8 +61,8 @@ btr_search_info_update(
dict_index_t* index, /*!< in: index of the cursor */ dict_index_t* index, /*!< in: index of the cursor */
btr_cur_t* cursor) /*!< in: cursor which was just positioned */ btr_cur_t* cursor) /*!< in: cursor which was just positioned */
{ {
ut_ad(!rw_lock_own(btr_get_search_latch(index), RW_LOCK_S)); ut_ad(!btr_search_own_any(RW_LOCK_S));
ut_ad(!rw_lock_own(btr_get_search_latch(index), RW_LOCK_X)); ut_ad(!btr_search_own_any(RW_LOCK_X));
if (dict_index_is_spatial(index) || !btr_search_enabled) { if (dict_index_is_spatial(index) || !btr_search_enabled) {
return; return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment