summaryrefslogtreecommitdiff
path: root/storage/innobase/btr/btr0sea.cc
diff options
context:
space:
mode:
Diffstat (limited to 'storage/innobase/btr/btr0sea.cc')
-rw-r--r--storage/innobase/btr/btr0sea.cc116
1 files changed, 42 insertions, 74 deletions
diff --git a/storage/innobase/btr/btr0sea.cc b/storage/innobase/btr/btr0sea.cc
index 866166d218b..81794676af1 100644
--- a/storage/innobase/btr/btr0sea.cc
+++ b/storage/innobase/btr/btr0sea.cc
@@ -1010,8 +1010,6 @@ both have sensible values.
we assume the caller uses his search latch
to protect the record!
@param[out] cursor tree cursor
-@param[in] ahi_latch the adaptive hash index latch being held,
- or NULL
@param[in] mtr mini transaction
@return whether the search succeeded */
bool
@@ -1022,23 +1020,18 @@ btr_search_guess_on_hash(
ulint mode,
ulint latch_mode,
btr_cur_t* cursor,
- rw_lock_t* ahi_latch,
mtr_t* mtr)
{
ulint fold;
index_id_t index_id;
ut_ad(mtr->is_active());
- ut_ad(!ahi_latch || rw_lock_own_flagged(
- ahi_latch, RW_LOCK_FLAG_X | RW_LOCK_FLAG_S));
if (!btr_search_enabled) {
return false;
}
ut_ad(!index->is_ibuf());
- ut_ad(!ahi_latch
- || ahi_latch == &btr_search_sys.get_part(*index)->latch);
ut_ad((latch_mode == BTR_SEARCH_LEAF)
|| (latch_mode == BTR_MODIFY_LEAF));
compile_time_assert(ulint{BTR_SEARCH_LEAF} == ulint{RW_S_LATCH});
@@ -1074,25 +1067,18 @@ btr_search_guess_on_hash(
auto part = btr_search_sys.get_part(*index);
const rec_t* rec;
- if (!ahi_latch) {
- rw_lock_s_lock(&part->latch);
+ rw_lock_s_lock(&part->latch);
- if (!btr_search_enabled) {
- goto fail;
- }
- } else {
- ut_ad(btr_search_enabled);
- ut_ad(rw_lock_own(ahi_latch, RW_LOCK_S));
+ if (!btr_search_enabled) {
+ goto fail;
}
rec = static_cast<const rec_t*>(
ha_search_and_get_data(&part->table, fold));
if (!rec) {
- if (!ahi_latch) {
fail:
- rw_lock_s_unlock(&part->latch);
- }
+ rw_lock_s_unlock(&part->latch);
btr_search_failure(info, cursor);
return false;
@@ -1100,59 +1086,51 @@ fail:
buf_block_t* block = buf_pool.block_from_ahi(rec);
- if (!ahi_latch) {
- page_hash_latch* hash_lock = buf_pool.hash_lock_get(
- block->page.id());
- hash_lock->read_lock();
+ page_hash_latch* hash_lock = buf_pool.hash_lock_get(block->page.id());
+ hash_lock->read_lock();
- if (block->page.state() == BUF_BLOCK_REMOVE_HASH) {
- /* Another thread is just freeing the block
- from the LRU list of the buffer pool: do not
- try to access this page. */
- hash_lock->read_unlock();
- goto fail;
- }
+ if (block->page.state() == BUF_BLOCK_REMOVE_HASH) {
+ /* Another thread is just freeing the block
+ from the LRU list of the buffer pool: do not
+ try to access this page. */
+ hash_lock->read_unlock();
+ goto fail;
+ }
- const bool fail = index != block->index
- && index_id == block->index->id;
- ut_a(!fail || block->index->freed());
- ut_ad(block->page.state() == BUF_BLOCK_FILE_PAGE);
- DBUG_ASSERT(fail || block->page.status != buf_page_t::FREED);
+ const bool fail = index != block->index
+ && index_id == block->index->id;
+ ut_a(!fail || block->index->freed());
+ ut_ad(block->page.state() == BUF_BLOCK_FILE_PAGE);
+ DBUG_ASSERT(fail || block->page.status != buf_page_t::FREED);
- buf_block_buf_fix_inc(block, __FILE__, __LINE__);
- hash_lock->read_unlock();
- block->page.set_accessed();
+ buf_block_buf_fix_inc(block, __FILE__, __LINE__);
+ hash_lock->read_unlock();
+ block->page.set_accessed();
- buf_page_make_young_if_needed(&block->page);
- mtr_memo_type_t fix_type;
- if (latch_mode == BTR_SEARCH_LEAF) {
- if (!rw_lock_s_lock_nowait(&block->lock,
- __FILE__, __LINE__)) {
+ buf_page_make_young_if_needed(&block->page);
+ mtr_memo_type_t fix_type;
+ if (latch_mode == BTR_SEARCH_LEAF) {
+ if (!rw_lock_s_lock_nowait(&block->lock, __FILE__, __LINE__)) {
got_no_latch:
- buf_block_buf_fix_dec(block);
- goto fail;
- }
- fix_type = MTR_MEMO_PAGE_S_FIX;
- } else {
- if (!rw_lock_x_lock_func_nowait_inline(
- &block->lock, __FILE__, __LINE__)) {
- goto got_no_latch;
- }
- fix_type = MTR_MEMO_PAGE_X_FIX;
+ buf_block_buf_fix_dec(block);
+ goto fail;
}
- mtr->memo_push(block, fix_type);
+ fix_type = MTR_MEMO_PAGE_S_FIX;
+ } else {
+ if (!rw_lock_x_lock_func_nowait_inline(
+ &block->lock, __FILE__, __LINE__)) {
+ goto got_no_latch;
+ }
+ fix_type = MTR_MEMO_PAGE_X_FIX;
+ }
+ mtr->memo_push(block, fix_type);
- buf_pool.stat.n_page_gets++;
+ buf_pool.stat.n_page_gets++;
- rw_lock_s_unlock(&part->latch);
+ rw_lock_s_unlock(&part->latch);
- buf_block_dbg_add_level(block, SYNC_TREE_NODE_FROM_HASH);
- if (UNIV_UNLIKELY(fail)) {
- goto fail_and_release_page;
- }
- } else if (UNIV_UNLIKELY(index != block->index
- && index_id == block->index->id)) {
- ut_a(block->index->freed());
+ buf_block_dbg_add_level(block, SYNC_TREE_NODE_FROM_HASH);
+ if (UNIV_UNLIKELY(fail)) {
goto fail_and_release_page;
}
@@ -1161,9 +1139,7 @@ got_no_latch:
ut_ad(block->page.state() == BUF_BLOCK_REMOVE_HASH);
fail_and_release_page:
- if (!ahi_latch) {
- btr_leaf_page_release(block, latch_mode, mtr);
- }
+ btr_leaf_page_release(block, latch_mode, mtr);
btr_search_failure(info, cursor);
return false;
@@ -1181,7 +1157,7 @@ fail_and_release_page:
record to determine if our guess for the cursor position is
right. */
if (index_id != btr_page_get_index_id(block->frame)
- || !btr_search_check_guess(cursor, !!ahi_latch, tuple, mode)) {
+ || !btr_search_check_guess(cursor, 0, tuple, mode)) {
goto fail_and_release_page;
}
@@ -1230,14 +1206,6 @@ fail_and_release_page:
#ifdef UNIV_SEARCH_PERF_STAT
btr_search_n_succ++;
#endif
- /* Increment the page get statistics though we did not really
- fix the page: for user info only */
- ++buf_pool.stat.n_page_gets;
-
- if (!ahi_latch) {
- buf_page_make_young_if_needed(&block->page);
- }
-
return true;
}