Commit 8442bc6e authored by Marko Mäkelä's avatar Marko Mäkelä

Cleanup: Remove an unnecessary page lookup

btr_cur_search_to_nth_level(): Simply acquire a latch on the already
buffer-fixed page. There is no need to release the buffer-fix and
re-lookup the page.
parent a5ed56cd
...@@ -1555,8 +1555,6 @@ dberr_t btr_cur_search_to_nth_level(dict_index_t *index, ulint level, ...@@ -1555,8 +1555,6 @@ dberr_t btr_cur_search_to_nth_level(dict_index_t *index, ulint level,
block = buf_page_get_gen(page_id, zip_size, rw_latch, guess, block = buf_page_get_gen(page_id, zip_size, rw_latch, guess,
buf_mode, mtr, &err, buf_mode, mtr, &err,
height == 0 && !index->is_clust()); height == 0 && !index->is_clust());
tree_blocks[n_blocks] = block;
if (!block) { if (!block) {
switch (err) { switch (err) {
case DB_SUCCESS: case DB_SUCCESS:
...@@ -1643,10 +1641,10 @@ dberr_t btr_cur_search_to_nth_level(dict_index_t *index, ulint level, ...@@ -1643,10 +1641,10 @@ dberr_t btr_cur_search_to_nth_level(dict_index_t *index, ulint level,
goto retry_page_get; goto retry_page_get;
} }
tree_blocks[n_blocks] = block;
if (height && prev_tree_blocks) { if (height && prev_tree_blocks) {
/* also latch left sibling */ /* also latch left sibling */
buf_block_t* get_block;
ut_ad(rw_latch == RW_NO_LATCH); ut_ad(rw_latch == RW_NO_LATCH);
rw_latch = upper_rw_latch; rw_latch = upper_rw_latch;
...@@ -1661,43 +1659,25 @@ dberr_t btr_cur_search_to_nth_level(dict_index_t *index, ulint level, ...@@ -1661,43 +1659,25 @@ dberr_t btr_cur_search_to_nth_level(dict_index_t *index, ulint level,
prev_tree_savepoints[prev_n_blocks] prev_tree_savepoints[prev_n_blocks]
= mtr_set_savepoint(mtr); = mtr_set_savepoint(mtr);
get_block = buf_page_get_gen( buf_block_t* get_block = buf_page_get_gen(
page_id_t(page_id.space(), left_page_no), page_id_t(page_id.space(), left_page_no),
zip_size, rw_latch, NULL, buf_mode, zip_size, rw_latch, NULL, buf_mode,
mtr, &err); mtr, &err);
prev_tree_blocks[prev_n_blocks] = get_block;
prev_n_blocks++;
if (!get_block) { if (!get_block) {
if (err == DB_DECRYPTION_FAILED) { if (err == DB_DECRYPTION_FAILED) {
btr_decryption_failed(*index); btr_decryption_failed(*index);
} }
goto func_exit; goto func_exit;
} }
prev_tree_blocks[prev_n_blocks++] = get_block;
/* BTR_MODIFY_TREE doesn't update prev/next_page_no, /* BTR_MODIFY_TREE doesn't update prev/next_page_no,
without their parent page's lock. So, not needed to without their parent page's lock. So, not needed to
retry here, because we have the parent page's lock. */ retry here, because we have the parent page's lock. */
} }
/* release RW_NO_LATCH page and lock with RW_S_LATCH */ mtr->s_lock_register(tree_savepoints[n_blocks]);
mtr_release_block_at_savepoint( block->page.lock.s_lock();
mtr, tree_savepoints[n_blocks],
tree_blocks[n_blocks]);
tree_savepoints[n_blocks] = mtr_set_savepoint(mtr);
block = buf_page_get_gen(page_id, zip_size,
rw_latch, NULL, buf_mode, mtr, &err);
tree_blocks[n_blocks] = block;
if (!block) {
if (err == DB_DECRYPTION_FAILED) {
btr_decryption_failed(*index);
}
goto func_exit;
}
} }
page = buf_block_get_frame(block); page = buf_block_get_frame(block);
......
...@@ -345,6 +345,15 @@ struct mtr_t { ...@@ -345,6 +345,15 @@ struct mtr_t {
slot->type= MTR_MEMO_PAGE_SX_FIX; slot->type= MTR_MEMO_PAGE_SX_FIX;
} }
/** Register a page latch on a buffer-fixed block was buffer-fixed.
@param latch latch type */
void s_lock_register(ulint savepoint)
{
mtr_memo_slot_t *slot= m_memo.at<mtr_memo_slot_t*>(savepoint);
ut_ad(slot->type == MTR_MEMO_BUF_FIX);
slot->type= MTR_MEMO_PAGE_S_FIX;
}
/** Upgrade U locks on a block to X */ /** Upgrade U locks on a block to X */
void page_lock_upgrade(const buf_block_t &block); void page_lock_upgrade(const buf_block_t &block);
/** Upgrade X lock to X */ /** Upgrade X lock to X */
......
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