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