summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThirunarayanan Balathandayuthapani <thiru@mariadb.com>2023-05-17 17:07:24 +0530
committerThirunarayanan Balathandayuthapani <thiru@mariadb.com>2023-05-17 17:07:24 +0530
commitb4efd8b0d6408a7434ce4da591c5035fa6aea02b (patch)
tree9d7464f87a11a3648270e5f7bd1fb1cd6d254eb5
parentfe70df784da27ec0ee3bb9a5f0db6d27476b6458 (diff)
downloadmariadb-git-bb-11.0-MDEV-14795.tar.gz
- Removed extent descriptor page from FSP_FREE_FRAG list and reducedbb-11.0-MDEV-14795
the FREE_FRAG_N_USED. - Removed the truncated pages from flush list
-rw-r--r--storage/innobase/fsp/fsp0fsp.cc83
1 files changed, 75 insertions, 8 deletions
diff --git a/storage/innobase/fsp/fsp0fsp.cc b/storage/innobase/fsp/fsp0fsp.cc
index e92efac49b7..7fa21716465 100644
--- a/storage/innobase/fsp/fsp0fsp.cc
+++ b/storage/innobase/fsp/fsp0fsp.cc
@@ -3078,18 +3078,19 @@ std::ostream &fseg_header::to_stream(std::ostream &out) const
@return DB_SUCCESS on success or error code */
static
void
-fsp_truncate_free_list(fil_space_t *space, buf_block_t *header,
- uint32_t threshold, mtr_t *mtr)
+fsp_truncate_list(fil_space_t *space, buf_block_t *header,
+ uint16_t hdr_offset, uint32_t threshold,
+ mtr_t *mtr)
{
const uint32_t len= flst_get_len(
- FSP_HEADER_OFFSET + FSP_FREE + header->page.frame);
+ FSP_HEADER_OFFSET + hdr_offset + header->page.frame);
if (len == 0)
return;
buf_block_t *descr_block= nullptr;
dberr_t err= DB_SUCCESS;
fil_addr_t addr= flst_get_first(
- header->page.frame + FSP_HEADER_OFFSET + FSP_FREE);
+ header->page.frame + FSP_HEADER_OFFSET + hdr_offset);
for (uint32_t i= len; i > 0; i--)
{
@@ -3106,16 +3107,26 @@ fsp_truncate_free_list(fil_space_t *space, buf_block_t *header,
{
/* Remove the truncated free list extents */
err= flst_remove(
- header, FSP_HEADER_OFFSET + FSP_FREE, descr_block,
+ header, FSP_HEADER_OFFSET + hdr_offset, descr_block,
static_cast<uint16_t>(descr - descr_block->page.frame
+ XDES_FLST_NODE), mtr);
- space->free_len--;
+ if (hdr_offset == FSP_FREE)
+ space->free_len--;
+ else
+ {
+ uint32_t frag_n_used= mach_read_from_4(
+ FSP_HEADER_OFFSET + FSP_FRAG_N_USED + header->page.frame);
+ frag_n_used-= 2;
+ mtr->write<4>(*header, FSP_HEADER_OFFSET + FSP_FRAG_N_USED
+ + header->page.frame, frag_n_used);
+ }
}
addr= flst_get_next_addr(b->page.frame + addr.boffset);
if (addr.page == FIL_NULL)
- return;
+ break;
}
+
return;
}
@@ -3252,8 +3263,64 @@ dberr_t fsp_tablespace_truncate(fil_space_t *space)
return err;
}
+ mysql_mutex_lock(&buf_pool.flush_list_mutex);
+ for (buf_page_t *bpage= UT_LIST_GET_LAST(buf_pool.flush_list); bpage; )
+ {
+ ut_ad(bpage->oldest_modification());
+ ut_ad(bpage->in_file());
+
+ buf_page_t *prev= UT_LIST_GET_PREV(list, bpage);
+
+ if (bpage->id().space() == space->id &&
+ bpage->id().page_no() >= last_used_extent &&
+ bpage->oldest_modification() != 1)
+ {
+ ut_ad(bpage->frame);
+ auto block= reinterpret_cast<buf_block_t*>(bpage);
+ if (!bpage->lock.x_lock_try())
+ {
+ rescan:
+ /* Let buf_pool_t::release_freed_page() proceed. */
+ mysql_mutex_unlock(&buf_pool.flush_list_mutex);
+ mysql_mutex_lock(&buf_pool.mutex);
+ mysql_mutex_lock(&buf_pool.flush_list_mutex);
+ mysql_mutex_unlock(&buf_pool.mutex);
+ bpage= UT_LIST_GET_LAST(buf_pool.flush_list);
+ continue;
+ }
+ buf_pool.flush_hp.set(prev);
+ mysql_mutex_unlock(&buf_pool.flush_list_mutex);
+
+#ifdef BTR_CUR_HASH_ADAPT
+ ut_ad(!block->index); /* There is no AHI on undo tablespaces. */
+#endif
+ bpage->fix();
+ ut_ad(!bpage->is_io_fixed());
+ mysql_mutex_lock(&buf_pool.flush_list_mutex);
+
+ if (bpage->oldest_modification() > 1)
+ {
+ bpage->reset_oldest_modification();
+ mtr.memo_push(block, MTR_MEMO_PAGE_X_FIX);
+ }
+ else
+ {
+ bpage->unfix();
+ bpage->lock.x_unlock();
+ }
+
+ if (prev != buf_pool.flush_hp.get())
+ /* Rescan, because we may have lost the position. */
+ goto rescan;
+ }
+
+ bpage= prev;
+ }
+
+ mysql_mutex_unlock(&buf_pool.flush_list_mutex);
mtr.trim_pages(page_id_t(space->id, last_used_extent));
- fsp_truncate_free_list(space, header, last_used_extent, &mtr);
+ fsp_truncate_list(space, header, FSP_FREE, last_used_extent, &mtr);
+ fsp_truncate_list(space, header, FSP_FREE_FRAG, last_used_extent, &mtr);
fsp_xdes_reset(space, last_used_extent, &mtr);
ib::info() <<"Truncating system tablespaces from " << space->size