Commit 5dbe7a8c authored by Marko Mäkelä's avatar Marko Mäkelä

Merge 10.5 into 10.6

parents 52ca2e65 a0f02f74
......@@ -1034,35 +1034,76 @@ static
buf_block_t*
fsp_page_create(fil_space_t *space, page_no_t offset, mtr_t *mtr)
{
buf_block_t *block, *free_block;
buf_block_t *block;
if (UNIV_UNLIKELY(space->is_being_truncated))
{
const page_id_t page_id{space->id, offset};
buf_pool_t::hash_chain &chain= buf_pool.page_hash.cell_get(page_id.fold());
mysql_mutex_lock(&buf_pool.mutex);
block= reinterpret_cast<buf_block_t*>
(buf_pool.page_hash.get(page_id, chain));
if (block && block->page.oldest_modification() <= 1)
block= nullptr;
mysql_mutex_unlock(&buf_pool.mutex);
uint32_t state;
block= mtr->get_already_latched(page_id, MTR_MEMO_PAGE_X_FIX);
if (block)
goto have_latch;
else
{
ut_ad(block->page.buf_fix_count() >= 1);
ut_ad(block->page.lock.x_lock_count() == 1);
ut_ad(mtr->have_x_latch(*block));
free_block= block;
goto got_free_block;
buf_pool_t::hash_chain &chain=
buf_pool.page_hash.cell_get(page_id.fold());
mysql_mutex_lock(&buf_pool.mutex);
block= reinterpret_cast<buf_block_t*>
(buf_pool.page_hash.get(page_id, chain));
if (!block)
{
mysql_mutex_unlock(&buf_pool.mutex);
goto create;
}
}
if (!mtr->have_x_latch(*block))
{
const bool got{block->page.lock.x_lock_try()};
mysql_mutex_unlock(&buf_pool.mutex);
if (!got)
{
block->page.lock.x_lock();
const page_id_t id{block->page.id()};
if (UNIV_UNLIKELY(id != page_id))
{
ut_ad(id.is_corrupted());
block->page.lock.x_unlock();
goto create;
}
}
state= block->page.fix() + 1;
mtr->memo_push(block, MTR_MEMO_PAGE_X_FIX);
}
else
{
mysql_mutex_unlock(&buf_pool.mutex);
have_latch:
state= block->page.state();
}
}
free_block= buf_LRU_get_free_block(false);
got_free_block:
block= buf_page_create(space, static_cast<uint32_t>(offset),
space->zip_size(), mtr, free_block);
if (UNIV_UNLIKELY(block != free_block))
buf_pool.free_block(free_block);
ut_ad(state > buf_page_t::FREED);
ut_ad(state < buf_page_t::READ_FIX);
ut_ad((state & buf_page_t::LRU_MASK) != buf_page_t::IBUF_EXIST);
ut_ad(block->page.lock.x_lock_count() == 1);
ut_ad(block->page.frame);
#ifdef BTR_CUR_HASH_ADAPT
ut_ad(!block->index);
#endif
block->page.set_reinit(state < buf_page_t::UNFIXED
? buf_page_t::FREED
: (state & buf_page_t::LRU_MASK));
}
else
{
create:
buf_block_t *free_block= buf_LRU_get_free_block(false);
block= buf_page_create(space, static_cast<uint32_t>(offset),
space->zip_size(), mtr, free_block);
if (UNIV_UNLIKELY(block != free_block))
buf_pool.free_block(free_block);
}
fsp_init_file_page(space, block, mtr);
return block;
......
......@@ -677,8 +677,8 @@ TRANSACTIONAL_TARGET void trx_purge_truncate_history()
mini-transaction commit and the server was killed, then
discarding the to-be-trimmed pages without flushing would
break crash recovery. */
rescan:
mysql_mutex_lock(&buf_pool.flush_list_mutex);
rescan:
for (buf_page_t *bpage= UT_LIST_GET_LAST(buf_pool.flush_list); bpage; )
{
ut_ad(bpage->oldest_modification());
......@@ -707,26 +707,20 @@ TRANSACTIONAL_TARGET void trx_purge_truncate_history()
ut_ad(!bpage->is_io_fixed());
ut_ad(bpage->id().space() == space_id);
if (bpage->oldest_modification() > 2)
{
if (bpage->oldest_modification() > 2 &&
!mtr.have_x_latch(*reinterpret_cast<buf_block_t*>(bpage)))
mtr.memo_push(reinterpret_cast<buf_block_t*>(bpage),
MTR_MEMO_PAGE_X_FIX);
mysql_mutex_lock(&buf_pool.flush_list_mutex);
ut_ad(bpage->oldest_modification() > 2);
bpage->reset_oldest_modification();
}
else
{
bpage->unfix();
bpage->lock.x_unlock();
mysql_mutex_lock(&buf_pool.flush_list_mutex);
}
mysql_mutex_lock(&buf_pool.flush_list_mutex);
if (prev != buf_pool.flush_hp.get())
{
mysql_mutex_unlock(&buf_pool.flush_list_mutex);
goto rescan;
}
}
bpage= prev;
......
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