summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2020-11-10 09:47:29 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2020-11-11 15:48:43 +0200
commitbd528b0c93409b81157314d9699af519fd9d52ce (patch)
tree8e070344b687204c87cd55c6b763f09faccdca35
parentcd927dd34555a34e733a01bf5af52470f57ce906 (diff)
downloadmariadb-git-bd528b0c93409b81157314d9699af519fd9d52ce.tar.gz
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 cd623508dff53c210154392da6c0f65b7b6bcf4c 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.
-rw-r--r--storage/innobase/buf/buf0buf.cc6
-rw-r--r--storage/innobase/ibuf/ibuf0ibuf.cc123
-rw-r--r--storage/innobase/include/ibuf0ibuf.h8
-rw-r--r--storage/innobase/log/log0recv.cc3
4 files changed, 50 insertions, 90 deletions
diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc
index e2b68011077..a54d98adee0 100644
--- a/storage/innobase/buf/buf0buf.cc
+++ b/storage/innobase/buf/buf0buf.cc
@@ -4601,7 +4601,7 @@ evict_from_pool:
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 @@ loop:
/* 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 @@ database_corrupted:
ibuf_merge_or_delete_for_page(
(buf_block_t*) bpage, bpage->id,
- &bpage->size, TRUE);
+ bpage->size);
}
fil_space_release_for_io(space);
diff --git a/storage/innobase/ibuf/ibuf0ibuf.cc b/storage/innobase/ibuf/ibuf0ibuf.cc
index 7068dab77a4..ee6fd235d5e 100644
--- a/storage/innobase/ibuf/ibuf0ibuf.cc
+++ b/storage/innobase/ibuf/ibuf0ibuf.cc
@@ -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 @@ loop:
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 @@ loop:
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 @@ loop:
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 @@ loop:
}
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);
}
}
diff --git a/storage/innobase/include/ibuf0ibuf.h b/storage/innobase/include/ibuf0ibuf.h
index a69b63ee16b..1a5214085de 100644
--- a/storage/innobase/include/ibuf0ibuf.h
+++ b/storage/innobase/include/ibuf0ibuf.h
@@ -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
diff --git a/storage/innobase/log/log0recv.cc b/storage/innobase/log/log0recv.cc
index 446e0afe576..4c3886caeaf 100644
--- a/storage/innobase/log/log0recv.cc
+++ b/storage/innobase/log/log0recv.cc
@@ -320,8 +320,7 @@ public:
&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);