summaryrefslogtreecommitdiff
path: root/storage/innobase/ibuf
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2018-03-27 16:31:10 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2018-03-29 22:02:05 +0300
commit4cad42392a2c498a2be92a77b21b1ec4027c9ea9 (patch)
treeb1f652d9f6488acb87d5cb206a2867f84124ee4c /storage/innobase/ibuf
parentc02c329a8e9e024c1dc2399284b29a13d8d85783 (diff)
downloadmariadb-git-4cad42392a2c498a2be92a77b21b1ec4027c9ea9.tar.gz
MDEV-12266: Change dict_table_t::space to fil_space_t*
InnoDB always keeps all tablespaces in the fil_system cache. The fil_system.LRU is only for closing file handles; the fil_space_t and fil_node_t for all data files will remain in main memory. Between startup to shutdown, they can only be created and removed by DDL statements. Therefore, we can let dict_table_t::space point directly to the fil_space_t. dict_table_t::space_id: A numeric tablespace ID for the corner cases where we do not have a tablespace. The most prominent examples are ALTER TABLE...DISCARD TABLESPACE or a missing or corrupted file. There are a few functional differences; most notably: (1) DROP TABLE will delete matching .ibd and .cfg files, even if they were not attached to the data dictionary. (2) Some error messages will report file names instead of numeric IDs. There still are many functions that use numeric tablespace IDs instead of fil_space_t*, and many functions could be converted to fil_space_t member functions. Also, Tablespace and Datafile should be merged with fil_space_t and fil_node_t. page_id_t and buf_page_get_gen() could use fil_space_t& instead of a numeric ID, and after moving to a single buffer pool (MDEV-15058), buf_pool_t::page_hash could be moved to fil_space_t::page_hash. FilSpace: Remove. Only few calls to fil_space_acquire() will remain, and gradually they should be removed. mtr_t::set_named_space_id(ulint): Renamed from set_named_space(), to prevent accidental calls to this slower function. Very few callers remain. fseg_create(), fsp_reserve_free_extents(): Take fil_space_t* as a parameter instead of a space_id. fil_space_t::rename(): Wrapper for fil_rename_tablespace_check(), fil_name_write_rename(), fil_rename_tablespace(). Mariabackup passes the parameter log=false; InnoDB passes log=true. dict_mem_table_create(): Take fil_space_t* instead of space_id as parameter. dict_process_sys_tables_rec_and_mtr_commit(): Replace the parameter 'status' with 'bool cached'. dict_get_and_save_data_dir_path(): Avoid copying the fil_node_t::name. fil_ibd_open(): Return the tablespace. fil_space_t::set_imported(): Replaces fil_space_set_imported(). truncate_t: Change many member function parameters to fil_space_t*, and remove page_size parameters. row_truncate_prepare(): Merge to its only caller. row_drop_table_from_cache(): Assert that the table is persistent. dict_create_sys_indexes_tuple(): Write SYS_INDEXES.SPACE=FIL_NULL if the tablespace has been discarded. row_import_update_discarded_flag(): Remove a constant parameter.
Diffstat (limited to 'storage/innobase/ibuf')
-rw-r--r--storage/innobase/ibuf/ibuf0ibuf.cc67
1 files changed, 28 insertions, 39 deletions
diff --git a/storage/innobase/ibuf/ibuf0ibuf.cc b/storage/innobase/ibuf/ibuf0ibuf.cc
index 07c4f0de4bc..1ff3cb594c6 100644
--- a/storage/innobase/ibuf/ibuf0ibuf.cc
+++ b/storage/innobase/ibuf/ibuf0ibuf.cc
@@ -561,7 +561,7 @@ ibuf_init_at_db_start(void)
ibuf->index = dict_mem_index_create(
dict_mem_table_create("innodb_change_buffer",
- IBUF_SPACE_ID, 1, 0, 0, 0),
+ fil_system.sys_space, 1, 0, 0, 0),
"CLUST_IND",
DICT_CLUSTERED | DICT_IBUF, 1);
ibuf->index->id = DICT_IBUF_ID_MIN + IBUF_SPACE_ID;
@@ -910,7 +910,8 @@ ibuf_set_free_bits_func(
}
mtr_start(&mtr);
- const fil_space_t* space = mtr.set_named_space(block->page.id.space());
+ const fil_space_t* space = mtr.set_named_space_id(
+ block->page.id.space());
bitmap_page = ibuf_bitmap_get_map_page(block->page.id,
block->page.size, &mtr);
@@ -1494,8 +1495,7 @@ ibuf_dummy_index_create(
dict_table_t* table;
dict_index_t* index;
- table = dict_mem_table_create("IBUF_DUMMY",
- DICT_HDR_SPACE, n, 0,
+ table = dict_mem_table_create("IBUF_DUMMY", NULL, n, 0,
comp ? DICT_TF_COMPACT : 0, 0);
index = dict_mem_index_create(table, "IBUF_DUMMY", 0, n);
@@ -2580,8 +2580,6 @@ ibuf_merge_space(
ut_ad(space < SRV_LOG_SPACE_FIRST_ID);
- ut_ad(space < SRV_LOG_SPACE_FIRST_ID);
-
ibuf_mtr_start(&mtr);
/* Position the cursor on the first matching record. */
@@ -3384,6 +3382,7 @@ ibuf_insert_low(
ut_ad(!dict_index_is_spatial(index));
ut_ad(dtuple_check_typed(entry));
ut_ad(!no_counter || op == IBUF_OP_INSERT);
+ ut_ad(page_id.space() == index->table->space->id);
ut_a(op < IBUF_OP_COUNT);
do_merge = FALSE;
@@ -3506,7 +3505,7 @@ fail_exit:
ut_a((buffered == 0) || ibuf_count_get(page_id));
#endif
ibuf_mtr_start(&bitmap_mtr);
- bitmap_mtr.set_named_space(page_id.space());
+ index->set_modified(bitmap_mtr);
bitmap_page = ibuf_bitmap_get_map_page(page_id, page_size,
&bitmap_mtr);
@@ -4574,7 +4573,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,
@@ -4590,7 +4589,7 @@ loop:
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());
+ mtr.set_named_space(space);
}
if (!btr_pcur_is_on_user_rec(&pcur)) {
@@ -4641,6 +4640,9 @@ loop:
entry = ibuf_build_entry_from_ibuf_rec(
&mtr, rec, heap, &dummy_index);
+ ut_ad(!dummy_index->table->space);
+ dummy_index->table->space = space;
+ dummy_index->table->space_id = space->id;
ut_ad(page_validate(block->frame, dummy_index));
@@ -4692,7 +4694,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,
@@ -4947,25 +4949,15 @@ ibuf_print(
mutex_exit(&ibuf_mutex);
}
-/******************************************************************//**
-Checks the insert buffer bitmaps on IMPORT TABLESPACE.
+/** Check the insert buffer bitmaps on IMPORT TABLESPACE.
+@param[in] trx transaction
+@param[in,out] space tablespace being imported
@return DB_SUCCESS or error code */
-dberr_t
-ibuf_check_bitmap_on_import(
-/*========================*/
- const trx_t* trx, /*!< in: transaction */
- ulint space_id) /*!< in: tablespace identifier */
+dberr_t ibuf_check_bitmap_on_import(const trx_t* trx, fil_space_t* space)
{
ulint page_no;
-
- ut_ad(space_id);
ut_ad(trx->mysql_thd);
-
- FilSpace space(space_id);
- if (!space()) {
- return(DB_TABLE_NOT_FOUND);
- }
-
+ ut_ad(space->purpose == FIL_TYPE_IMPORT);
const page_size_t page_size(space->flags);
/* fil_space_t::size and fil_space_t::free_limit would still be 0
at this point. So, we will have to read page 0. */
@@ -4975,7 +4967,7 @@ ibuf_check_bitmap_on_import(
mtr_t mtr;
ulint size;
mtr.start();
- if (buf_block_t* sp = buf_page_get(page_id_t(space_id, 0), page_size,
+ if (buf_block_t* sp = buf_page_get(page_id_t(space->id, 0), page_size,
RW_S_LATCH, &mtr)) {
size = std::min(
mach_read_from_4(FSP_HEADER_OFFSET + FSP_FREE_LIMIT
@@ -5015,7 +5007,7 @@ ibuf_check_bitmap_on_import(
ibuf_enter(&mtr);
bitmap_page = ibuf_bitmap_get_map_page(
- page_id_t(space_id, page_no), page_size, &mtr);
+ page_id_t(space->id, page_no), page_size, &mtr);
if (buf_page_is_zeroes(bitmap_page, page_size)) {
/* This means we got all-zero page instead of
@@ -5026,9 +5018,8 @@ ibuf_check_bitmap_on_import(
curr_page < page_size.physical(); curr_page++) {
buf_block_t* block = buf_page_get(
- page_id_t(space_id, curr_page),
- page_size,
- RW_S_LATCH, &mtr);
+ page_id_t(space->id, curr_page),
+ page_size, RW_S_LATCH, &mtr);
page_t* page = buf_block_get_frame(block);
ut_ad(buf_page_is_zeroes(page, page_size));
}
@@ -5044,7 +5035,7 @@ ibuf_check_bitmap_on_import(
const ulint offset = page_no + i;
- const page_id_t cur_page_id(space_id, offset);
+ const page_id_t cur_page_id(space->id, offset);
if (ibuf_bitmap_page_get_bits(
bitmap_page, cur_page_id, page_size,
@@ -5057,12 +5048,10 @@ ibuf_check_bitmap_on_import(
ib_errf(trx->mysql_thd,
IB_LOG_LEVEL_ERROR,
ER_INNODB_INDEX_CORRUPT,
- "Space %u page %u"
+ "File %s page " ULINTPF
" is wrongly flagged to belong to the"
" insert buffer",
- (unsigned) space_id,
- (unsigned) offset);
-
+ space->chain.start->name, offset);
return(DB_CORRUPTION);
}
@@ -5074,9 +5063,9 @@ ibuf_check_bitmap_on_import(
IB_LOG_LEVEL_WARN,
ER_INNODB_INDEX_CORRUPT,
"Buffered changes"
- " for space %u page %u are lost",
- (unsigned) space_id,
- (unsigned) offset);
+ " for file %s page " ULINTPF
+ " are lost",
+ space->chain.start->name, offset);
/* Tolerate this error, so that
slightly corrupted tables can be
@@ -5112,7 +5101,7 @@ ibuf_set_bitmap_for_bulk_load(
free_val = ibuf_index_page_calc_free(block);
mtr_start(&mtr);
- mtr.set_named_space(block->page.id.space());
+ mtr.set_named_space_id(block->page.id.space());
bitmap_page = ibuf_bitmap_get_map_page(block->page.id,
block->page.size, &mtr);