MDEV-34458 wait_for_read in buf_page_get_low hurts performance
BTR_MODIFY_PREV: Remove. This mode was only used by the change buffer, which commit f27e9c894779a4c7ebe6446ba9aa408f1771c114 (MDEV-29694) removed. buf_page_get_gen(): Revert the change that was made in commit 90b95c6149c72f43aa2324353a76f370d018a5ac (MDEV-33543) because it is not applicable after MDEV-29694. This fixes the performance regression that Vladislav Vaintroub reported. This is a 11.x specific fix; this needs to be fixed differently in older major versions where the change buffer is present.
This commit is contained in:
parent
cc1363071a
commit
2f6df93748
@ -1220,7 +1220,7 @@ dberr_t btr_cur_t::search_leaf(const dtuple_t *tuple, page_cur_mode_t mode,
|
||||
ut_ad(rw_lock_type_t(latch_mode & ~12) == RW_X_LATCH);
|
||||
goto relatch_x;
|
||||
}
|
||||
if (latch_mode != BTR_MODIFY_PREV)
|
||||
else
|
||||
{
|
||||
if (!latch_by_caller)
|
||||
/* Release the tree s-latch */
|
||||
@ -1292,8 +1292,6 @@ dberr_t btr_cur_t::search_leaf(const dtuple_t *tuple, page_cur_mode_t mode,
|
||||
|
||||
switch (latch_mode) {
|
||||
case BTR_SEARCH_PREV:
|
||||
case BTR_MODIFY_PREV:
|
||||
static_assert(BTR_MODIFY_PREV & BTR_MODIFY_LEAF, "");
|
||||
static_assert(BTR_SEARCH_PREV & BTR_SEARCH_LEAF, "");
|
||||
ut_ad(!latch_by_caller);
|
||||
ut_ad(rw_latch ==
|
||||
@ -1470,7 +1468,6 @@ release_tree:
|
||||
case BTR_MODIFY_ROOT_AND_LEAF:
|
||||
rw_latch= RW_X_LATCH;
|
||||
break;
|
||||
case BTR_MODIFY_PREV: /* btr_pcur_move_to_prev() */
|
||||
case BTR_SEARCH_PREV: /* btr_pcur_move_to_prev() */
|
||||
ut_ad(rw_latch == RW_S_LATCH || rw_latch == RW_X_LATCH);
|
||||
|
||||
@ -1854,7 +1851,6 @@ dberr_t btr_cur_t::open_leaf(bool first, dict_index_t *index,
|
||||
ut_ad(!(latch_mode & 8));
|
||||
/* This function doesn't need to lock left page of the leaf page */
|
||||
static_assert(int{BTR_SEARCH_PREV} == (4 | BTR_SEARCH_LEAF), "");
|
||||
static_assert(int{BTR_MODIFY_PREV} == (4 | BTR_MODIFY_LEAF), "");
|
||||
latch_mode= btr_latch_mode(latch_mode & (RW_S_LATCH | RW_X_LATCH));
|
||||
ut_ad(!latch_by_caller ||
|
||||
mtr->memo_contains_flagged(&index->lock,
|
||||
|
@ -215,24 +215,18 @@ static bool btr_pcur_optimistic_latch_leaves(btr_pcur_t *pcur,
|
||||
btr_latch_mode *latch_mode,
|
||||
mtr_t *mtr)
|
||||
{
|
||||
static_assert(BTR_SEARCH_PREV & BTR_SEARCH_LEAF, "");
|
||||
static_assert(BTR_MODIFY_PREV & BTR_MODIFY_LEAF, "");
|
||||
static_assert((BTR_SEARCH_PREV ^ BTR_MODIFY_PREV) ==
|
||||
(RW_S_LATCH ^ RW_X_LATCH), "");
|
||||
|
||||
buf_block_t *const block=
|
||||
buf_page_optimistic_fix(pcur->btr_cur.page_cur.block, pcur->old_page_id);
|
||||
|
||||
if (!block)
|
||||
return false;
|
||||
|
||||
if (*latch_mode == BTR_SEARCH_LEAF || *latch_mode == BTR_MODIFY_LEAF)
|
||||
if (*latch_mode != BTR_SEARCH_PREV)
|
||||
{
|
||||
ut_ad(*latch_mode == BTR_SEARCH_LEAF || *latch_mode == BTR_MODIFY_LEAF);
|
||||
return buf_page_optimistic_get(block, rw_lock_type_t(*latch_mode),
|
||||
pcur->modify_clock, mtr);
|
||||
|
||||
ut_ad(*latch_mode == BTR_SEARCH_PREV || *latch_mode == BTR_MODIFY_PREV);
|
||||
const rw_lock_type_t mode=
|
||||
rw_lock_type_t(*latch_mode & (RW_X_LATCH | RW_S_LATCH));
|
||||
}
|
||||
|
||||
uint64_t modify_clock;
|
||||
uint32_t left_page_no;
|
||||
@ -258,7 +252,7 @@ static bool btr_pcur_optimistic_latch_leaves(btr_pcur_t *pcur,
|
||||
{
|
||||
prev= buf_page_get_gen(page_id_t(pcur->old_page_id.space(),
|
||||
left_page_no), block->zip_size(),
|
||||
mode, nullptr, BUF_GET_POSSIBLY_FREED, mtr);
|
||||
RW_S_LATCH, nullptr, BUF_GET_POSSIBLY_FREED, mtr);
|
||||
if (!prev ||
|
||||
page_is_comp(prev->page.frame) != page_is_comp(block->page.frame) ||
|
||||
memcmp_aligned<2>(block->page.frame, prev->page.frame, 2) ||
|
||||
@ -269,7 +263,7 @@ static bool btr_pcur_optimistic_latch_leaves(btr_pcur_t *pcur,
|
||||
else
|
||||
prev= nullptr;
|
||||
|
||||
mtr->upgrade_buffer_fix(savepoint, mode);
|
||||
mtr->upgrade_buffer_fix(savepoint, RW_S_LATCH);
|
||||
|
||||
if (UNIV_UNLIKELY(block->modify_clock != modify_clock) ||
|
||||
UNIV_UNLIKELY(block->page.is_freed()) ||
|
||||
@ -343,11 +337,9 @@ btr_pcur_t::restore_position(btr_latch_mode restore_latch_mode, mtr_t *mtr)
|
||||
ut_a(old_n_fields);
|
||||
|
||||
static_assert(BTR_SEARCH_PREV == (4 | BTR_SEARCH_LEAF), "");
|
||||
static_assert(BTR_MODIFY_PREV == (4 | BTR_MODIFY_LEAF), "");
|
||||
|
||||
switch (restore_latch_mode | 4) {
|
||||
case BTR_SEARCH_PREV:
|
||||
case BTR_MODIFY_PREV:
|
||||
/* Try optimistic restoration. */
|
||||
if (btr_pcur_optimistic_latch_leaves(this, &restore_latch_mode,
|
||||
mtr)) {
|
||||
@ -579,7 +571,6 @@ btr_pcur_move_backward_from_page(
|
||||
mtr_start(mtr);
|
||||
|
||||
static_assert(BTR_SEARCH_PREV == (4 | BTR_SEARCH_LEAF), "");
|
||||
static_assert(BTR_MODIFY_PREV == (4 | BTR_MODIFY_LEAF), "");
|
||||
|
||||
if (UNIV_UNLIKELY(cursor->restore_position(
|
||||
btr_latch_mode(4 | latch_mode), mtr)
|
||||
|
@ -2740,15 +2740,7 @@ ignore_unfixed:
|
||||
in buf_page_t::read_complete() or
|
||||
buf_pool_t::corrupted_evict(), or
|
||||
after buf_zip_decompress() in this function. */
|
||||
if (rw_latch != RW_NO_LATCH) {
|
||||
block->page.lock.s_lock();
|
||||
} else if (!block->page.lock.s_lock_try()) {
|
||||
/* For RW_NO_LATCH, we should not try to acquire S or X
|
||||
latch directly as we could be violating the latching
|
||||
order resulting in deadlock. Instead we try latching the
|
||||
page and retry in case of a failure. */
|
||||
goto wait_for_read;
|
||||
}
|
||||
block->page.lock.s_lock();
|
||||
state = block->page.state();
|
||||
ut_ad(state < buf_page_t::READ_FIX
|
||||
|| state >= buf_page_t::WRITE_FIX);
|
||||
@ -2756,15 +2748,15 @@ ignore_unfixed:
|
||||
block->page.lock.s_unlock();
|
||||
|
||||
if (UNIV_UNLIKELY(state < buf_page_t::UNFIXED)) {
|
||||
block->page.unfix();
|
||||
if (UNIV_UNLIKELY(id == page_id)) {
|
||||
/* The page read was completed, and
|
||||
another thread marked the page as free
|
||||
while we were waiting. */
|
||||
goto ignore_block;
|
||||
goto ignore_unfixed;
|
||||
}
|
||||
|
||||
ut_ad(id == page_id_t{~0ULL});
|
||||
block->page.unfix();
|
||||
|
||||
if (++retries < BUF_PAGE_READ_MAX_RETRIES) {
|
||||
goto loop;
|
||||
@ -2803,7 +2795,6 @@ free_unfixed_block:
|
||||
if (UNIV_UNLIKELY(!block->page.frame)) {
|
||||
if (!block->page.lock.x_lock_try()) {
|
||||
wait_for_unzip:
|
||||
wait_for_read:
|
||||
/* The page is being read or written, or
|
||||
another thread is executing buf_zip_decompress()
|
||||
in buf_page_get_gen() on it. */
|
||||
|
@ -604,7 +604,6 @@ dberr_t rtr_search_to_nth_level(btr_cur_t *cur, que_thr_t *thr,
|
||||
upper_rw_latch= RW_X_LATCH;
|
||||
break;
|
||||
default:
|
||||
ut_ad(latch_mode != BTR_MODIFY_PREV);
|
||||
ut_ad(latch_mode != BTR_SEARCH_PREV);
|
||||
if (!latch_by_caller)
|
||||
mtr_s_lock_index(index, mtr);
|
||||
|
@ -68,9 +68,6 @@ enum btr_latch_mode {
|
||||
/** Search the previous record.
|
||||
Used in btr_pcur_move_backward_from_page(). */
|
||||
BTR_SEARCH_PREV = 4 | BTR_SEARCH_LEAF,
|
||||
/** Modify the previous record.
|
||||
Used in btr_pcur_move_backward_from_page(). */
|
||||
BTR_MODIFY_PREV = 4 | BTR_MODIFY_LEAF,
|
||||
/** Start modifying the entire B-tree. */
|
||||
BTR_MODIFY_TREE = 8 | BTR_MODIFY_LEAF,
|
||||
/** Continue modifying the entire R-tree.
|
||||
|
Loading…
x
Reference in New Issue
Block a user