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

MDEV-24182 ibuf_merge_or_delete_for_page() contains dead code

The function ibuf_merge_or_delete_for_page() was always being
invoked with update_ibuf_bitmap=true ever since
commit cd623508
fixed up something after MDEV-9566.

Furthermore, the parameter page_size is never being passed as a
null pointer, and therefore it should better be a reference to
a constant object.
parent cd927dd3
......@@ -4601,7 +4601,7 @@ buf_page_get_low(
if (!access_time && !recv_no_ibuf_operations) {
ibuf_merge_or_delete_for_page(
block, page_id, &page_size, TRUE);
block, page_id, page_size);
}
buf_pool_mutex_enter(buf_pool);
......@@ -5678,7 +5678,7 @@ buf_page_create(
/* Delete possible entries for the page from the insert buffer:
such can exist if the page belonged to an index which was dropped */
if (!recv_recovery_is_on()) {
ibuf_merge_or_delete_for_page(NULL, page_id, &page_size, TRUE);
ibuf_merge_or_delete_for_page(NULL, page_id, page_size);
}
frame = block->frame;
......@@ -6133,7 +6133,7 @@ buf_page_io_complete(buf_page_t* bpage, bool dblwr, bool evict)
ibuf_merge_or_delete_for_page(
(buf_block_t*) bpage, bpage->id,
&bpage->size, TRUE);
bpage->size);
}
fil_space_release_for_io(space);
......
......@@ -4384,16 +4384,12 @@ exist entries for such a page if the page belonged to an index which
subsequently was dropped.
@param[in,out] block if page has been read from disk,
pointer to the page x-latched, else NULL
@param[in] page_id page id of the index page
@param[in] update_ibuf_bitmap normally this is set to TRUE, but
if we have deleted or are deleting the tablespace, then we naturally do not
want to update a non-existent bitmap page */
@param[in] page_id page id of the index page */
void
ibuf_merge_or_delete_for_page(
buf_block_t* block,
const page_id_t page_id,
const page_size_t* page_size,
ibool update_ibuf_bitmap)
const page_size_t& page_size)
{
btr_pcur_t pcur;
#ifdef UNIV_IBUF_DEBUG
......@@ -4417,81 +4413,50 @@ ibuf_merge_or_delete_for_page(
return;
}
/* We cannot refer to page_size in the following, because it is passed
as NULL (it is unknown) when buf_read_ibuf_merge_pages() is merging
(discarding) changes for a dropped tablespace. When block != NULL or
update_ibuf_bitmap is specified, then page_size must be known.
That is why we will repeat the check below, with page_size in
place of univ_page_size. Passing univ_page_size assumes that the
uncompressed page size always is a power-of-2 multiple of the
compressed page size. */
if (ibuf_fixed_addr_page(page_id, univ_page_size)
|| fsp_descr_page(page_id, univ_page_size)) {
if (ibuf_fixed_addr_page(page_id, page_size)
|| fsp_descr_page(page_id, page_size)) {
return;
}
fil_space_t* space;
if (update_ibuf_bitmap) {
ut_ad(page_size != NULL);
if (ibuf_fixed_addr_page(page_id, *page_size)
|| fsp_descr_page(page_id, *page_size)) {
return;
}
fil_space_t* space = fil_space_acquire_silent(page_id.space());
space = fil_space_acquire_silent(page_id.space());
if (UNIV_UNLIKELY(!space)) {
/* Do not try to read the bitmap page from the
non-existent tablespace, delete the ibuf records */
block = NULL;
update_ibuf_bitmap = FALSE;
} else {
page_t* bitmap_page = NULL;
ulint bitmap_bits = 0;
if (UNIV_UNLIKELY(!space)) {
block = NULL;
} else {
page_t* bitmap_page = NULL;
ulint bitmap_bits = 0;
ibuf_mtr_start(&mtr);
ibuf_mtr_start(&mtr);
bitmap_page = ibuf_bitmap_get_map_page(
page_id, *page_size, &mtr);
bitmap_page = ibuf_bitmap_get_map_page(
page_id, page_size, &mtr);
if (bitmap_page &&
fil_page_get_type(bitmap_page) != FIL_PAGE_TYPE_ALLOCATED) {
bitmap_bits = ibuf_bitmap_page_get_bits(
bitmap_page, page_id, *page_size,
IBUF_BITMAP_BUFFERED, &mtr);
}
if (bitmap_page &&
fil_page_get_type(bitmap_page) != FIL_PAGE_TYPE_ALLOCATED) {
bitmap_bits = ibuf_bitmap_page_get_bits(
bitmap_page, page_id, page_size,
IBUF_BITMAP_BUFFERED, &mtr);
}
ibuf_mtr_commit(&mtr);
ibuf_mtr_commit(&mtr);
if (!bitmap_bits) {
/* No changes are buffered for this page. */
fil_space_release(space);
if (UNIV_UNLIKELY(srv_shutdown_state)
&& !srv_fast_shutdown
&& (!block
|| btr_page_get_index_id(block->frame)
!= DICT_IBUF_ID_MIN + IBUF_SPACE_ID)) {
/* Prevent an infinite loop on slow
shutdown, in case the bitmap bits are
wrongly clear even though buffered
changes exist. */
ibuf_delete_recs(page_id);
}
return;
if (!bitmap_bits) {
/* No changes are buffered for this page. */
fil_space_release(space);
if (UNIV_UNLIKELY(srv_shutdown_state)
&& !srv_fast_shutdown
&& (!block
|| btr_page_get_index_id(block->frame)
!= DICT_IBUF_ID_MIN + IBUF_SPACE_ID)) {
/* Prevent an infinite loop on slow
shutdown, in case the bitmap bits are
wrongly clear even though buffered
changes exist. */
ibuf_delete_recs(page_id);
}
return;
}
} else if (block != NULL
&& (ibuf_fixed_addr_page(page_id, *page_size)
|| fsp_descr_page(page_id, *page_size))) {
return;
} else {
space = NULL;
}
mem_heap_t* heap = mem_heap_create(512);
......@@ -4541,7 +4506,7 @@ ibuf_merge_or_delete_for_page(
if (block != NULL) {
ibool success;
mtr.set_named_space(page_id.space());
mtr.set_named_space(space);
success = buf_page_get_known_nowait(
RW_X_LATCH, block,
......@@ -4556,8 +4521,8 @@ ibuf_merge_or_delete_for_page(
the block is io-fixed. Other threads must not try to
latch an io-fixed block. */
buf_block_dbg_add_level(block, SYNC_IBUF_TREE_NODE);
} else if (update_ibuf_bitmap) {
mtr.set_named_space(page_id.space());
} else if (space) {
mtr.set_named_space(space);
}
if (!btr_pcur_is_on_user_rec(&pcur)) {
......@@ -4658,7 +4623,7 @@ ibuf_merge_or_delete_for_page(
ibuf_btr_pcur_commit_specify_mtr(&pcur, &mtr);
ibuf_mtr_start(&mtr);
mtr.set_named_space(page_id.space());
mtr.set_named_space(space);
success = buf_page_get_known_nowait(
RW_X_LATCH, block,
......@@ -4714,26 +4679,26 @@ ibuf_merge_or_delete_for_page(
}
reset_bit:
if (update_ibuf_bitmap) {
if (space) {
page_t* bitmap_page;
bitmap_page = ibuf_bitmap_get_map_page(page_id, *page_size,
bitmap_page = ibuf_bitmap_get_map_page(page_id, page_size,
&mtr);
ibuf_bitmap_page_set_bits(
bitmap_page, page_id, *page_size,
bitmap_page, page_id, page_size,
IBUF_BITMAP_BUFFERED, FALSE, &mtr);
if (block != NULL) {
ulint old_bits = ibuf_bitmap_page_get_bits(
bitmap_page, page_id, *page_size,
bitmap_page, page_id, page_size,
IBUF_BITMAP_FREE, &mtr);
ulint new_bits = ibuf_index_page_calc_free(block);
if (old_bits != new_bits) {
ibuf_bitmap_page_set_bits(
bitmap_page, page_id, *page_size,
bitmap_page, page_id, page_size,
IBUF_BITMAP_FREE, new_bits, &mtr);
}
}
......
......@@ -342,16 +342,12 @@ exist entries for such a page if the page belonged to an index which
subsequently was dropped.
@param[in,out] block if page has been read from disk,
pointer to the page x-latched, else NULL
@param[in] page_id page id of the index page
@param[in] update_ibuf_bitmap normally this is set to TRUE, but
if we have deleted or are deleting the tablespace, then we naturally do not
want to update a non-existent bitmap page */
@param[in] page_id page id of the index page */
void
ibuf_merge_or_delete_for_page(
buf_block_t* block,
const page_id_t page_id,
const page_size_t* page_size,
ibool update_ibuf_bitmap);
const page_size_t& page_size);
/*********************************************************************//**
Deletes all entries in the insert buffer for a given space id. This is used
......
......@@ -320,8 +320,7 @@ class mlog_init_t
&mtr, NULL)) {
mutex_exit(&recv_sys->mutex);
ibuf_merge_or_delete_for_page(
block, i->first,
&block->page.size, true);
block, i->first, block->page.size);
mtr.commit();
mtr.start();
mutex_enter(&recv_sys->mutex);
......
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