summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2016-12-16 16:36:54 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2016-12-16 16:36:54 +0200
commitd0ae4686fd9faab728082cb6ce063bf5eaa0773c (patch)
tree4df9f65921166cea2c1e4486e59acf68ab721020
parentce55094f4fee3c0ff2c58ac4dd3ef2c16c5e20c3 (diff)
downloadmariadb-git-bb-10.2-mdev-11585.tar.gz
MDEV-11585 Hard-code the shared InnoDB temporary tablespace ID at -1bb-10.2-mdev-11585
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.
-rw-r--r--storage/innobase/btr/btr0btr.cc2
-rw-r--r--storage/innobase/buf/buf0buf.cc2
-rw-r--r--storage/innobase/dict/dict0crea.cc3
-rw-r--r--storage/innobase/fil/fil0fil.cc11
-rw-r--r--storage/innobase/fsp/fsp0fsp.cc53
-rw-r--r--storage/innobase/fsp/fsp0space.cc11
-rw-r--r--storage/innobase/ibuf/ibuf0ibuf.cc3
-rw-r--r--storage/innobase/include/fsp0space.h5
-rw-r--r--storage/innobase/include/fsp0sysspace.h11
-rw-r--r--storage/innobase/include/fsp0types.h13
-rw-r--r--storage/innobase/include/srv0start.h3
-rw-r--r--storage/innobase/row/row0trunc.cc2
-rw-r--r--storage/innobase/srv/srv0start.cc41
-rw-r--r--storage/innobase/trx/trx0sys.cc3
14 files changed, 70 insertions, 93 deletions
diff --git a/storage/innobase/btr/btr0btr.cc b/storage/innobase/btr/btr0btr.cc
index e5284ee802a..31ba56d2993 100644
--- a/storage/innobase/btr/btr0btr.cc
+++ b/storage/innobase/btr/btr0btr.cc
@@ -1097,7 +1097,7 @@ btr_free_root_check(
index_id_t index_id,
mtr_t* mtr)
{
- ut_ad(page_id.space() != srv_tmp_space.space_id());
+ ut_ad(page_id.space() != SRV_TMP_SPACE_ID);
ut_ad(index_id != BTR_FREED_INDEX_ID);
buf_block_t* block = buf_page_get(
diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc
index d3b4f12e69b..43683d63c97 100644
--- a/storage/innobase/buf/buf0buf.cc
+++ b/storage/innobase/buf/buf0buf.cc
@@ -6092,7 +6092,7 @@ corrupt:
#endif /* MYSQL_COMPRESSION */
&& !recv_no_ibuf_operations
&& !Tablespace::is_undo_tablespace(bpage->id.space())
- && bpage->id.space() != srv_tmp_space.space_id()
+ && bpage->id.space() != SRV_TMP_SPACE_ID
&& !srv_is_tablespace_truncated(bpage->id.space())
&& fil_page_get_type(frame) == FIL_PAGE_INDEX
&& page_is_leaf(frame)) {
diff --git a/storage/innobase/dict/dict0crea.cc b/storage/innobase/dict/dict0crea.cc
index 2d891854c03..cfea64d51c2 100644
--- a/storage/innobase/dict/dict0crea.cc
+++ b/storage/innobase/dict/dict0crea.cc
@@ -571,8 +571,7 @@ dict_build_tablespace_for_table(
supports Redundant and Compact */
ut_ad(dict_tf_get_rec_format(table->flags)
!= REC_FORMAT_COMPRESSED);
- table->space = static_cast<uint32_t>(
- srv_tmp_space.space_id());
+ table->space = SRV_TMP_SPACE_ID;
} else {
/* Create in the system tablespace. */
ut_ad(table->space == srv_sys_space.space_id());
diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc
index 596c6bdfdb0..26e0593b266 100644
--- a/storage/innobase/fil/fil0fil.cc
+++ b/storage/innobase/fil/fil0fil.cc
@@ -185,7 +185,7 @@ fil_is_user_tablespace_id(
ulint space_id)
{
return(space_id > srv_undo_tablespaces_open
- && space_id != srv_tmp_space.space_id());
+ && space_id != SRV_TMP_SPACE_ID);
}
#ifdef UNIV_DEBUG
@@ -1313,7 +1313,7 @@ fil_space_create(
/* This warning is not applicable while MEB scanning the redo logs */
#ifndef UNIV_HOTBACKUP
- if (fil_type_is_data(purpose)
+ if ((purpose == FIL_TYPE_TABLESPACE || purpose == FIL_TYPE_IMPORT)
&& !recv_recovery_on
&& id > fil_system->max_assigned_id) {
@@ -5104,10 +5104,13 @@ retry:
ulint pages_per_mb = (1024 * 1024) / page_size;
ulint size_in_pages = ((node->size / pages_per_mb) * pages_per_mb);
- if (space->id == srv_sys_space.space_id()) {
+ switch (space->id) {
+ case TRX_SYS_SPACE:
srv_sys_space.set_last_file_size(size_in_pages);
- } else if (space->id == srv_tmp_space.space_id()) {
+ break;
+ case SRV_TMP_SPACE_ID:
srv_tmp_space.set_last_file_size(size_in_pages);
+ break;
}
#else
ib::trace() << "extended space : " << space->name << " from "
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'.
diff --git a/storage/innobase/ibuf/ibuf0ibuf.cc b/storage/innobase/ibuf/ibuf0ibuf.cc
index e9ad1a9d8c0..4b1c3704123 100644
--- a/storage/innobase/ibuf/ibuf0ibuf.cc
+++ b/storage/innobase/ibuf/ibuf0ibuf.cc
@@ -3727,9 +3727,10 @@ ibuf_insert(
op, page_id.space(), page_id.page_no()));
ut_ad(dtuple_check_typed(entry));
- ut_ad(page_id.space() != srv_tmp_space.space_id());
+ ut_ad(page_id.space() != SRV_TMP_SPACE_ID);
ut_a(!dict_index_is_clust(index));
+ ut_ad(!dict_table_is_temporary(index->table));
no_counter = use <= IBUF_USE_INSERT;
diff --git a/storage/innobase/include/fsp0space.h b/storage/innobase/include/fsp0space.h
index 603c71b4aa6..31a1a4abc75 100644
--- a/storage/innobase/include/fsp0space.h
+++ b/storage/innobase/include/fsp0space.h
@@ -219,7 +219,10 @@ public:
/** Check if undo tablespace.
@return true if undo tablespace */
- static bool is_undo_tablespace(ulint id);
+ static bool is_undo_tablespace(ulint id)
+ {
+ return(id <= srv_undo_tablespaces_open);
+ }
private:
/**
@param[in] filename Name to lookup in the data files.
diff --git a/storage/innobase/include/fsp0sysspace.h b/storage/innobase/include/fsp0sysspace.h
index 226d53ebd50..c25093491a2 100644
--- a/storage/innobase/include/fsp0sysspace.h
+++ b/storage/innobase/include/fsp0sysspace.h
@@ -291,11 +291,9 @@ extern SysTablespace srv_tmp_space;
@return true if id is a system tablespace, false if not. */
UNIV_INLINE
bool
-is_system_tablespace(
- ulint id)
+is_system_tablespace(ulint id)
{
- return(id == srv_sys_space.space_id()
- || id == srv_tmp_space.space_id());
+ return(id == TRX_SYS_SPACE || id == SRV_TMP_SPACE_ID);
}
/** Check if shared-system or undo tablespace.
@@ -305,8 +303,7 @@ bool
is_system_or_undo_tablespace(
ulint id)
{
- return(id == srv_sys_space.space_id()
- || id <= srv_undo_tablespaces_open);
+ return(id <= srv_undo_tablespaces_open);
}
/** Check if predefined shared tablespace.
@@ -319,6 +316,6 @@ is_predefined_tablespace(
ut_ad(srv_sys_space.space_id() == TRX_SYS_SPACE);
ut_ad(TRX_SYS_SPACE == 0);
return(id <= srv_undo_tablespaces_open
- || id == srv_tmp_space.space_id());
+ || id == SRV_TMP_SPACE_ID);
}
#endif /* fsp0sysspace_h */
diff --git a/storage/innobase/include/fsp0types.h b/storage/innobase/include/fsp0types.h
index 21951acf72b..f9197394bd7 100644
--- a/storage/innobase/include/fsp0types.h
+++ b/storage/innobase/include/fsp0types.h
@@ -29,6 +29,12 @@ Created May 26, 2009 Vasil Dimov
#ifndef UNIV_INNOCHECKSUM
+/** The fil_space_t::id of the redo log. All persistent tablespaces
+have a smaller fil_space_t::id. */
+#define SRV_LOG_SPACE_FIRST_ID 0xFFFFFFF0U
+/** The fil_space_t::id of the innodb_temporary tablespace. */
+#define SRV_TMP_SPACE_ID 0xFFFFFFFFU
+
#include "univ.i"
#include "ut0byte.h"
@@ -196,9 +202,12 @@ fsp_flags_is_valid(
/** Check if tablespace is system temporary.
@param[in] space_id verify is checksum is enabled for given space.
@return true if tablespace is system temporary. */
+inline
bool
-fsp_is_system_temporary(
- ulint space_id);
+fsp_is_system_temporary(ulint space_id)
+{
+ return(space_id == SRV_TMP_SPACE_ID);
+}
/** Check if checksum is disabled for the given space.
@param[in] space_id verify is checksum is enabled for given space.
diff --git a/storage/innobase/include/srv0start.h b/storage/innobase/include/srv0start.h
index 82b5446c62a..708a90247e3 100644
--- a/storage/innobase/include/srv0start.h
+++ b/storage/innobase/include/srv0start.h
@@ -46,9 +46,6 @@ struct dict_table_t;
} while (0)
#endif /* DBUG_OFF */
-/** Log 'spaces' have id's >= this */
-#define SRV_LOG_SPACE_FIRST_ID 0xFFFFFFF0UL
-
/** If buffer pool is less than the size,
only one buffer pool instance is used. */
#define BUF_POOL_SIZE_THRESHOLD (1024 * 1024 * 1024)
diff --git a/storage/innobase/row/row0trunc.cc b/storage/innobase/row/row0trunc.cc
index 25dc274b0c5..1c118dabc61 100644
--- a/storage/innobase/row/row0trunc.cc
+++ b/storage/innobase/row/row0trunc.cc
@@ -2278,7 +2278,7 @@ truncate_t::fixup_tables_in_non_system_tablespace()
"id (" << (*it)->m_space_id << ")";
/* Temp-tables in temp-tablespace are never restored.*/
- ut_ad((*it)->m_space_id != srv_tmp_space.space_id());
+ ut_ad((*it)->m_space_id != SRV_TMP_SPACE_ID);
err = fil_recreate_table(
(*it)->m_space_id,
diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc
index 96c2d8fa8c4..49c9feb6ac5 100644
--- a/storage/innobase/srv/srv0start.cc
+++ b/storage/innobase/srv/srv0start.cc
@@ -1123,76 +1123,67 @@ srv_start_wait_for_purge_to_start()
/** Create the temporary file tablespace.
@param[in] create_new_db whether we are creating a new database
-@param[in,out] tmp_space Shared Temporary SysTablespace
@return DB_SUCCESS or error code. */
static
dberr_t
-srv_open_tmp_tablespace(
- bool create_new_db,
- SysTablespace* tmp_space)
+srv_open_tmp_tablespace(bool create_new_db)
{
ulint sum_of_new_sizes;
/* Will try to remove if there is existing file left-over by last
unclean shutdown */
- tmp_space->set_sanity_check_status(true);
- tmp_space->delete_files();
- tmp_space->set_ignore_read_only(true);
+ srv_tmp_space.set_sanity_check_status(true);
+ srv_tmp_space.delete_files();
+ srv_tmp_space.set_ignore_read_only(true);
ib::info() << "Creating shared tablespace for temporary tables";
bool create_new_temp_space;
- ulint temp_space_id = ULINT_UNDEFINED;
-
- dict_hdr_get_new_id(NULL, NULL, &temp_space_id, NULL, true);
- tmp_space->set_space_id(temp_space_id);
+ srv_tmp_space.set_space_id(SRV_TMP_SPACE_ID);
RECOVERY_CRASH(100);
- dberr_t err = tmp_space->check_file_spec(
- &create_new_temp_space, 12 * 1024 * 1024);
+ dberr_t err = srv_tmp_space.check_file_spec(
+ &create_new_temp_space, 12 * 1024 * 1024);
if (err == DB_FAIL) {
- ib::error() << "The " << tmp_space->name()
+ ib::error() << "The " << srv_tmp_space.name()
<< " data file must be writable!";
err = DB_ERROR;
} else if (err != DB_SUCCESS) {
ib::error() << "Could not create the shared "
- << tmp_space->name() << ".";
+ << srv_tmp_space.name() << ".";
- } else if ((err = tmp_space->open_or_create(
+ } else if ((err = srv_tmp_space.open_or_create(
true, create_new_db, &sum_of_new_sizes, NULL))
!= DB_SUCCESS) {
ib::error() << "Unable to create the shared "
- << tmp_space->name();
+ << srv_tmp_space.name();
} else {
mtr_t mtr;
- ulint size = tmp_space->get_sum_of_sizes();
-
- ut_a(temp_space_id != ULINT_UNDEFINED);
- ut_a(tmp_space->space_id() == temp_space_id);
+ ulint size = srv_tmp_space.get_sum_of_sizes();
/* Open this shared temp tablespace in the fil_system so that
it stays open until shutdown. */
- if (fil_space_open(tmp_space->name())) {
+ if (fil_space_open(srv_tmp_space.name())) {
/* Initialize the header page */
mtr_start(&mtr);
mtr_set_log_mode(&mtr, MTR_LOG_NO_REDO);
- fsp_header_init(tmp_space->space_id(), size, &mtr);
+ fsp_header_init(SRV_TMP_SPACE_ID, size, &mtr);
mtr_commit(&mtr);
} else {
/* This file was just opened in the code above! */
- ib::error() << "The " << tmp_space->name()
+ ib::error() << "The " << srv_tmp_space.name()
<< " data file cannot be re-opened"
" after check_file_spec() succeeded!";
@@ -2439,7 +2430,7 @@ files_checked:
/* Open temp-tablespace and keep it open until shutdown. */
- err = srv_open_tmp_tablespace(create_new_db, &srv_tmp_space);
+ err = srv_open_tmp_tablespace(create_new_db);
if (err != DB_SUCCESS) {
return(srv_init_abort(err));
diff --git a/storage/innobase/trx/trx0sys.cc b/storage/innobase/trx/trx0sys.cc
index a253ea72e95..0dd5e0a6335 100644
--- a/storage/innobase/trx/trx0sys.cc
+++ b/storage/innobase/trx/trx0sys.cc
@@ -983,8 +983,7 @@ trx_sys_create_noredo_rsegs(
Slot-1....Slot-N: reserved for temp-tablespace.
Slot-N+1....Slot-127: reserved for system/undo-tablespace. */
for (ulint i = 0; i < n_nonredo_rseg; i++) {
- ulint space = srv_tmp_space.space_id();
- if (trx_rseg_create(space, i) == NULL) {
+ if (trx_rseg_create(SRV_TMP_SPACE_ID, i) == NULL) {
break;
}
++n_created;