diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2016-12-16 16:36:54 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2016-12-19 16:24:10 +0200 |
commit | 8375a2c1cec3c386f6db797d75f64b8f03c83b37 (patch) | |
tree | 3ccb76d486f6949dd9120d85884366da7f0feff6 /storage/innobase/fsp | |
parent | c35b8c46b404d035e54a23d667da5dff6502fc2e (diff) | |
download | mariadb-git-8375a2c1cec3c386f6db797d75f64b8f03c83b37.tar.gz |
MDEV-11585 Hard-code the shared InnoDB temporary tablespace ID at -1
MySQL 5.7 supports only one shared temporary tablespace.
MariaDB 10.2 does not support any other shared InnoDB tablespaces than
the two predefined tablespaces: the persistent InnoDB system tablespace
(default file name ibdata1) and the temporary tablespace
(default file name ibtmp1).
InnoDB is unnecessarily allocating a tablespace ID for the predefined
temporary tablespace on every startup, and it is in several places
testing whether a tablespace ID matches this dynamically generated ID.
We should use a compile-time constant to reduce code size and to avoid
unnecessary updates to the DICT_HDR page at every startup.
Using a hard-coded tablespace ID will should make it easier to remove the
TEMPORARY flag from FSP_SPACE_FLAGS in MDEV-11202.
Diffstat (limited to 'storage/innobase/fsp')
-rw-r--r-- | storage/innobase/fsp/fsp0fsp.cc | 53 | ||||
-rw-r--r-- | storage/innobase/fsp/fsp0space.cc | 11 |
2 files changed, 21 insertions, 43 deletions
diff --git a/storage/innobase/fsp/fsp0fsp.cc b/storage/innobase/fsp/fsp0fsp.cc index 9dc99f3f09d..f2a4c6bf218 100644 --- a/storage/innobase/fsp/fsp0fsp.cc +++ b/storage/innobase/fsp/fsp0fsp.cc @@ -338,16 +338,6 @@ err_exit: return (false); } -/** Check if tablespace is system temporary. -@param[in] space_id tablespace ID -@return true if tablespace is system temporary. */ -bool -fsp_is_system_temporary( - ulint space_id) -{ - return(space_id == srv_tmp_space.space_id()); -} - /** Check if checksum is disabled for the given space. @param[in] space_id tablespace ID @return true if checksum is disabled for given space. */ @@ -803,8 +793,7 @@ fsp_space_modify_check( #ifdef UNIV_DEBUG { const fil_type_t type = fil_space_get_type(id); - ut_a(id == srv_tmp_space.space_id() - || srv_is_tablespace_truncated(id) + ut_a(srv_is_tablespace_truncated(id) || fil_space_is_being_truncated(id) || fil_space_get_flags(id) == ULINT_UNDEFINED || type == FIL_TYPE_TEMPORARY @@ -814,10 +803,7 @@ fsp_space_modify_check( #endif /* UNIV_DEBUG */ return; case MTR_LOG_ALL: - /* We must not write redo log for the shared temporary - tablespace. */ - ut_ad(id != srv_tmp_space.space_id()); - /* If we write redo log, the tablespace must exist. */ + /* We may only write redo log for a persistent tablespace. */ ut_ad(fil_space_get_type(id) == FIL_TYPE_TABLESPACE); ut_ad(mtr->is_named_space(id)); return; @@ -1549,15 +1535,14 @@ fsp_try_extend_data_file( const page_size_t page_size( mach_read_from_4(header + FSP_SPACE_FLAGS)); - if (space->id == srv_sys_space.space_id()) { - + switch (space->id) { + case TRX_SYS_SPACE: size_increase = srv_sys_space.get_increment(); - - } else if (space->id == srv_tmp_space.space_id()) { - + break; + case SRV_TMP_SPACE_ID: size_increase = srv_tmp_space.get_increment(); - - } else { + break; + default: ulint extent_pages = fsp_get_extent_size_in_pages(page_size); if (size < extent_pages) { @@ -1679,11 +1664,17 @@ fsp_fill_free_list( const page_size_t page_size(flags); if (size < limit + FSP_EXTENT_SIZE * FSP_FREE_ADD) { - if ((!init_space && !is_system_tablespace(space->id)) - || (space->id == srv_sys_space.space_id() - && srv_sys_space.can_auto_extend_last_file()) - || (space->id == srv_tmp_space.space_id() - && srv_tmp_space.can_auto_extend_last_file())) { + bool skip_resize = init_space; + switch (space->id) { + case TRX_SYS_SPACE: + skip_resize = !srv_sys_space.can_auto_extend_last_file(); + break; + case SRV_TMP_SPACE_ID: + skip_resize = srv_tmp_space.can_auto_extend_last_file(); + break; + } + + if (!skip_resize) { ulint n_pages = 0; fsp_try_extend_data_file(space, header, mtr, &n_pages); size = space->size_in_header; @@ -1733,7 +1724,7 @@ fsp_fill_free_list( order, and we must be able to release its latch. Note: Insert-Buffering is disabled for tables that reside in the temp-tablespace. */ - if (space->id != srv_tmp_space.space_id()) { + if (space->purpose != FIL_TYPE_TEMPORARY) { mtr_t ibuf_mtr; mtr_start(&ibuf_mtr); @@ -1741,9 +1732,7 @@ fsp_fill_free_list( /* Avoid logging while truncate table fix-up is active. */ - if (space->purpose == FIL_TYPE_TEMPORARY - || srv_is_tablespace_truncated( - space->id)) { + if (srv_is_tablespace_truncated(space->id)) { mtr_set_log_mode( &ibuf_mtr, MTR_LOG_NO_REDO); } diff --git a/storage/innobase/fsp/fsp0space.cc b/storage/innobase/fsp/fsp0space.cc index f66f7b8fc78..371baee627c 100644 --- a/storage/innobase/fsp/fsp0space.cc +++ b/storage/innobase/fsp/fsp0space.cc @@ -207,17 +207,6 @@ Tablespace::delete_files() } } -/** Check if undo tablespace. -@return true if undo tablespace */ -bool -Tablespace::is_undo_tablespace( - ulint id) -{ - return(id <= srv_undo_tablespaces_open - && id != srv_sys_space.space_id() - && id != srv_tmp_space.space_id()); -} - /** Use the ADD DATAFILE path to create a Datafile object and add it to the front of m_files. Parse the datafile path into a path and a filename with extension 'ibd'. |