summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2020-03-09 20:53:20 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2020-03-09 20:53:20 +0200
commit803c142491dcfd0307495425b6d29c4264cdfbc7 (patch)
tree0908cf08ff03b0e579c41d5d1511da58f9b1ed17
parent467f64b72864ac2b38e57234124237ad9b1ec763 (diff)
downloadmariadb-git-bb-10.5-MDEV-15528-latest.tar.gz
MDEV-15528: Simplify buf_page_create()bb-10.5-MDEV-15528-latest
buf_page_create(): Let the callers assign buf_page_t::status. Every caller should eventually invoke mtr_t::init(). fsp_page_create(): Remove the unused mtr_t parameter. In all other callers of buf_page_create() except fsp_page_create(), before invoking mtr_t::init(), invoke mtr_t::sx_latch_at_savepoint() or mtr_t::x_latch_at_savepoint(). mtr_t::init(): Initialize buf_page_t::status also for the temporary tablespace (when redo logging is disabled), to avoid assertion failures.
-rw-r--r--storage/innobase/buf/buf0buf.cc15
-rw-r--r--storage/innobase/fsp/fsp0fsp.cc49
-rw-r--r--storage/innobase/include/buf0buf.h5
-rw-r--r--storage/innobase/include/mtr0log.h3
4 files changed, 30 insertions, 42 deletions
diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc
index 3d90380eaf3..7ae510a8851 100644
--- a/storage/innobase/buf/buf0buf.cc
+++ b/storage/innobase/buf/buf0buf.cc
@@ -4930,21 +4930,20 @@ buf_page_create(
if (block
&& buf_page_in_file(&block->page)
&& !buf_pool_watch_is_sentinel(&block->page)) {
- BPageMutex* block_mutex = buf_page_get_mutex(&block->page);
- mutex_enter(block_mutex);
-
/* Page can be found in buf_pool */
mutex_exit(&buf_pool->mutex);
rw_lock_x_unlock(hash_lock);
- block->page.status = buf_page_t::NORMAL;
- mutex_exit(block_mutex);
-
buf_block_free(free_block);
if (!recv_recovery_is_on()) {
- return buf_page_get_with_no_latch(page_id, zip_size,
- mtr);
+ /* FIXME: Remove the redundant lookup and avoid
+ the unnecessary invocation of buf_zip_decompress().
+ We may have to convert buf_page_t to buf_block_t,
+ but we are going to initialize the page. */
+ return buf_page_get_gen(page_id, zip_size, RW_NO_LATCH,
+ block, BUF_GET_POSSIBLY_FREED,
+ __FILE__, __LINE__, mtr);
}
mutex_exit(&recv_sys.mutex);
diff --git a/storage/innobase/fsp/fsp0fsp.cc b/storage/innobase/fsp/fsp0fsp.cc
index 99f17f9224d..c47a1d0a95c 100644
--- a/storage/innobase/fsp/fsp0fsp.cc
+++ b/storage/innobase/fsp/fsp0fsp.cc
@@ -554,8 +554,10 @@ void fsp_header_init(fil_space_t* space, ulint size, mtr_t* mtr)
const ulint zip_size = space->zip_size();
mtr_x_lock_space(space, mtr);
+
+ const auto savepoint = mtr->get_savepoint();
buf_block_t* block = buf_page_create(page_id, zip_size, mtr);
- buf_page_get(page_id, zip_size, RW_SX_LATCH, mtr);
+ mtr->sx_latch_at_savepoint(savepoint, block);
buf_block_dbg_add_level(block, SYNC_FSP_PAGE);
space->size_in_header = size;
@@ -873,16 +875,12 @@ fsp_fill_free_list(
pages should be ignored. */
if (i > 0) {
- const page_id_t page_id(space->id, i);
-
- block = buf_page_create(
- page_id, zip_size, mtr);
-
- buf_page_get(
- page_id, zip_size, RW_SX_LATCH, mtr);
+ const auto savepoint = mtr->get_savepoint();
+ block= buf_page_create(page_id_t(space->id, i),
+ zip_size, mtr);
+ mtr->sx_latch_at_savepoint(savepoint, block);
buf_block_dbg_add_level(block, SYNC_FSP_PAGE);
-
fsp_init_file_page(space, block, mtr);
mtr->write<2>(*block,
FIL_PAGE_TYPE + block->frame,
@@ -900,17 +898,11 @@ fsp_fill_free_list(
ibuf_mtr.start();
ibuf_mtr.set_named_space(space);
- const page_id_t page_id(
- space->id,
- i + FSP_IBUF_BITMAP_OFFSET);
-
block = buf_page_create(
- page_id, zip_size, &ibuf_mtr);
-
- buf_page_get(
- page_id, zip_size, RW_SX_LATCH,
- &ibuf_mtr);
-
+ page_id_t(space->id,
+ i + FSP_IBUF_BITMAP_OFFSET),
+ zip_size, &ibuf_mtr);
+ ibuf_mtr.sx_latch_at_savepoint(0, block);
buf_block_dbg_add_level(block, SYNC_FSP_PAGE);
fsp_init_file_page(space, block, &ibuf_mtr);
@@ -1060,8 +1052,7 @@ fsp_alloc_from_free_frag(buf_block_t *header, buf_block_t *xdes, xdes_t *descr,
@param[in,out] space tablespace
@param[in] offset page number of the allocated page
@param[in] rw_latch RW_SX_LATCH, RW_X_LATCH
-@param[in,out] mtr mini-transaction of the allocation
-@param[in,out] init_mtr mini-transaction for initializing the page
+@param[in,out] mtr mini-transaction
@return block, initialized */
static
buf_block_t*
@@ -1069,13 +1060,13 @@ fsp_page_create(
fil_space_t* space,
page_no_t offset,
rw_lock_type_t rw_latch,
- mtr_t* mtr,
- mtr_t* init_mtr)
+ mtr_t* mtr)
{
buf_block_t* block = buf_page_create(page_id_t(space->id, offset),
- space->zip_size(), init_mtr);
+ space->zip_size(), mtr);
- /* Mimic buf_page_get(), but avoid the buf_pool->page_hash lookup. */
+ /* The latch may already have been acquired, so we cannot invoke
+ mtr_t::x_latch_at_savepoint() or mtr_t::sx_latch_at_savepoint(). */
mtr_memo_type_t memo;
if (rw_latch == RW_X_LATCH) {
@@ -1087,9 +1078,9 @@ fsp_page_create(
memo = MTR_MEMO_PAGE_SX_FIX;
}
- mtr_memo_push(init_mtr, block, memo);
+ mtr_memo_push(mtr, block, memo);
buf_block_buf_fix_inc(block, __FILE__, __LINE__);
- fsp_init_file_page(space, block, init_mtr);
+ fsp_init_file_page(space, block, mtr);
return(block);
}
@@ -1202,7 +1193,7 @@ fsp_alloc_free_page(
}
fsp_alloc_from_free_frag(block, xdes, descr, free, mtr);
- return fsp_page_create(space, page_no, rw_latch, mtr, init_mtr);
+ return fsp_page_create(space, page_no, rw_latch, init_mtr);
}
/** Frees a single page of a space.
@@ -2233,7 +2224,7 @@ got_hinted_page:
xdes, mtr);
}
- return fsp_page_create(space, ret_page, rw_latch, mtr, init_mtr);
+ return fsp_page_create(space, ret_page, rw_latch, init_mtr);
}
/**********************************************************************//**
diff --git a/storage/innobase/include/buf0buf.h b/storage/innobase/include/buf0buf.h
index 614da25dd13..3afb6e49431 100644
--- a/storage/innobase/include/buf0buf.h
+++ b/storage/innobase/include/buf0buf.h
@@ -372,10 +372,7 @@ FILE_PAGE (the other is buf_page_get_gen).
@param[in,out] mtr mini-transaction
@return pointer to the block, page bufferfixed */
buf_block_t*
-buf_page_create(
- const page_id_t page_id,
- ulint zip_size,
- mtr_t* mtr);
+buf_page_create(const page_id_t page_id, ulint zip_size, mtr_t *mtr);
/********************************************************************//**
Releases a compressed-only page acquired with buf_page_get_zip(). */
diff --git a/storage/innobase/include/mtr0log.h b/storage/innobase/include/mtr0log.h
index a6a8f696b87..29765faa017 100644
--- a/storage/innobase/include/mtr0log.h
+++ b/storage/innobase/include/mtr0log.h
@@ -502,6 +502,8 @@ inline void mtr_t::memcpy(const buf_block_t &b, void *dest, const void *str,
@param[in,out] b buffer page */
inline void mtr_t::init(buf_block_t *b)
{
+ b->page.status= buf_page_t::INIT_ON_FLUSH;
+
if (m_log_mode != MTR_LOG_ALL)
{
ut_ad(m_log_mode == MTR_LOG_NONE || m_log_mode == MTR_LOG_NO_REDO);
@@ -510,7 +512,6 @@ inline void mtr_t::init(buf_block_t *b)
m_log.close(log_write<INIT_PAGE>(b->page.id, &b->page));
m_last_offset= FIL_PAGE_TYPE;
- b->page.status= buf_page_t::INIT_ON_FLUSH;
}
/** Free a page.