Commit 1b95118c authored by Marko Mäkelä's avatar Marko Mäkelä

buf_page_get_gen(): Allow BUF_GET_IF_IN_POOL with a dummy page_size

The page_size argument to buf_page_get_gen() only matters when the
page is going to be loaded into the buffer pool. Allow callers to
pass a dummy parameter when using BUF_GET_IF_IN_POOL (which would
return NULL if the block is not in the buffer pool).
parent 80f29211
/***************************************************************************** /*****************************************************************************
Copyright (c) 2014, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2014, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, 2018, MariaDB Corporation. Copyright (c) 2017, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software the terms of the GNU General Public License as published by the Free Software
...@@ -664,10 +664,9 @@ PageBulk::latch() ...@@ -664,10 +664,9 @@ PageBulk::latch()
/* In case the block is S-latched by page_cleaner. */ /* In case the block is S-latched by page_cleaner. */
if (!buf_page_optimistic_get(RW_X_LATCH, m_block, m_modify_clock, if (!buf_page_optimistic_get(RW_X_LATCH, m_block, m_modify_clock,
__FILE__, __LINE__, &m_mtr)) { __FILE__, __LINE__, &m_mtr)) {
page_id_t page_id(dict_index_get_space(m_index), m_page_no); m_block = buf_page_get_gen(page_id_t(m_index->space,
page_size_t page_size(dict_table_page_size(m_index->table)); m_page_no),
univ_page_size, RW_X_LATCH,
m_block = buf_page_get_gen(page_id, page_size, RW_X_LATCH,
m_block, BUF_GET_IF_IN_POOL, m_block, BUF_GET_IF_IN_POOL,
__FILE__, __LINE__, &m_mtr, &m_err); __FILE__, __LINE__, &m_mtr, &m_err);
......
...@@ -4211,12 +4211,15 @@ buf_page_get_gen( ...@@ -4211,12 +4211,15 @@ buf_page_get_gen(
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
switch (mode) { switch (mode) {
case BUF_EVICT_IF_IN_POOL: case BUF_EVICT_IF_IN_POOL:
case BUF_PEEK_IF_IN_POOL:
/* After DISCARD TABLESPACE, the tablespace would not exist, /* After DISCARD TABLESPACE, the tablespace would not exist,
but in IMPORT TABLESPACE, PageConverter::operator() must but in IMPORT TABLESPACE, PageConverter::operator() must
replace any old pages, which were not evicted during DISCARD. replace any old pages, which were not evicted during DISCARD.
Similarly, btr_search_drop_page_hash_when_freed() must Skip the assertion on space_page_size. */
remove any old pages. Skip the assertion on page_size. */ break;
case BUF_PEEK_IF_IN_POOL:
case BUF_GET_IF_IN_POOL:
/* The caller may pass a dummy page size,
because it does not really matter. */
break; break;
default: default:
ut_error; ut_error;
...@@ -4224,7 +4227,6 @@ buf_page_get_gen( ...@@ -4224,7 +4227,6 @@ buf_page_get_gen(
ut_ad(rw_latch == RW_NO_LATCH); ut_ad(rw_latch == RW_NO_LATCH);
/* fall through */ /* fall through */
case BUF_GET: case BUF_GET:
case BUF_GET_IF_IN_POOL:
case BUF_GET_IF_IN_POOL_OR_WATCH: case BUF_GET_IF_IN_POOL_OR_WATCH:
case BUF_GET_POSSIBLY_FREED: case BUF_GET_POSSIBLY_FREED:
bool found; bool found;
......
...@@ -2261,35 +2261,25 @@ void recv_apply_hashed_log_recs(bool last_batch) ...@@ -2261,35 +2261,25 @@ void recv_apply_hashed_log_recs(bool last_batch)
continue; continue;
} }
const page_id_t page_id(recv_addr->space, const page_id_t page_id(recv_addr->space,
recv_addr->page_no); recv_addr->page_no);
bool found;
const page_size_t& page_size
= fil_space_get_page_size(recv_addr->space,
&found);
ut_ad(found);
if (recv_addr->state == RECV_NOT_PROCESSED) { if (recv_addr->state == RECV_NOT_PROCESSED) {
mutex_exit(&recv_sys->mutex); mutex_exit(&recv_sys->mutex);
mtr_t mtr;
if (buf_page_peek(page_id)) { mtr.start();
mtr_t mtr; if (buf_block_t* block = buf_page_get_gen(
mtr.start(); page_id, univ_page_size,
RW_X_LATCH, NULL,
buf_block_t* block = buf_page_get( BUF_GET_IF_IN_POOL,
page_id, page_size, __FILE__, __LINE__, &mtr, NULL)) {
RW_X_LATCH, &mtr);
buf_block_dbg_add_level( buf_block_dbg_add_level(
block, SYNC_NO_ORDER_CHECK); block, SYNC_NO_ORDER_CHECK);
recv_recover_page(FALSE, block); recv_recover_page(FALSE, block);
mtr.commit();
} else { } else {
recv_read_in_area(page_id); recv_read_in_area(page_id);
} }
mtr.commit();
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