diff --git a/mysql-test/suite/sys_vars/r/sysvars_innodb,32bit.rdiff b/mysql-test/suite/sys_vars/r/sysvars_innodb,32bit.rdiff index 9bf02940d75..2b9e9ad6baf 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_innodb,32bit.rdiff +++ b/mysql-test/suite/sys_vars/r/sysvars_innodb,32bit.rdiff @@ -571,9 +571,9 @@ VARIABLE_SCOPE GLOBAL -VARIABLE_TYPE BIGINT UNSIGNED +VARIABLE_TYPE INT UNSIGNED - VARIABLE_COMMENT Number of undo tablespaces to use. + VARIABLE_COMMENT Number of undo tablespaces to use. NUMERIC_MIN_VALUE 0 - NUMERIC_MAX_VALUE 95 + NUMERIC_MAX_VALUE 127 @@ -2630,7 +2630,7 @@ GLOBAL_VALUE_ORIGIN CONFIG DEFAULT_VALUE 4 diff --git a/mysql-test/suite/sys_vars/r/sysvars_innodb.result b/mysql-test/suite/sys_vars/r/sysvars_innodb.result index 8d142d6795d..70ba7371334 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_innodb.result +++ b/mysql-test/suite/sys_vars/r/sysvars_innodb.result @@ -2505,9 +2505,9 @@ GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE 0 VARIABLE_SCOPE GLOBAL VARIABLE_TYPE BIGINT UNSIGNED -VARIABLE_COMMENT Number of undo tablespaces to use. +VARIABLE_COMMENT Number of undo tablespaces to use. NUMERIC_MIN_VALUE 0 -NUMERIC_MAX_VALUE 95 +NUMERIC_MAX_VALUE 127 NUMERIC_BLOCK_SIZE 0 ENUM_VALUE_LIST NULL READ_ONLY YES diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 12ea9af99d3..5a5af11ec92 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -4487,7 +4487,7 @@ innobase_change_buffering_inited_ok: os_thread_sleep(20); } - srv_was_started = TRUE; + srv_was_started = true; /* Adjust the innodb_undo_logs config object */ innobase_undo_logs_init_default_max(); @@ -21477,11 +21477,11 @@ static MYSQL_SYSVAR_STR(undo_directory, srv_undo_dir, static MYSQL_SYSVAR_ULONG(undo_tablespaces, srv_undo_tablespaces, PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, - "Number of undo tablespaces to use. ", + "Number of undo tablespaces to use.", NULL, NULL, 0L, /* Default seting */ 0L, /* Minimum value */ - 95L, 0); /* Maximum value */ + TRX_SYS_MAX_UNDO_SPACES, 0); /* Maximum value */ static MYSQL_SYSVAR_ULONG(undo_logs, srv_undo_logs, PLUGIN_VAR_OPCMDARG, diff --git a/storage/innobase/include/srv0srv.h b/storage/innobase/include/srv0srv.h index c3c59cd93d4..8e3659a50e1 100644 --- a/storage/innobase/include/srv0srv.h +++ b/storage/innobase/include/srv0srv.h @@ -301,6 +301,9 @@ extern long srv_mtflush_threads; /* If this flag is TRUE, then we will use multi threaded flush. */ extern my_bool srv_use_mtflush; +/** TRUE if the server was successfully started */ +extern bool srv_was_started; + /** Server undo tablespaces directory, can be absolute path. */ extern char* srv_undo_dir; diff --git a/storage/innobase/include/srv0start.h b/storage/innobase/include/srv0start.h index d7a5922c954..4f2f4a312ff 100644 --- a/storage/innobase/include/srv0start.h +++ b/storage/innobase/include/srv0start.h @@ -121,8 +121,6 @@ extern lsn_t srv_start_lsn; extern bool srv_is_being_started; /** TRUE if SYS_TABLESPACES is available for lookups */ extern bool srv_sys_tablespaces_open; -/** TRUE if the server was successfully started */ -extern ibool srv_was_started; /** TRUE if the server is being started, before rolling back any incomplete transactions */ extern bool srv_startup_is_before_trx_rollback_phase; diff --git a/storage/innobase/include/trx0rseg.h b/storage/innobase/include/trx0rseg.h index 95774cbf476..4c162526384 100644 --- a/storage/innobase/include/trx0rseg.h +++ b/storage/innobase/include/trx0rseg.h @@ -200,7 +200,10 @@ struct trx_rseg_t { bool is_persistent() const { ut_ad(space == SRV_TMP_SPACE_ID - || space <= srv_undo_tablespaces); + || space <= TRX_SYS_MAX_UNDO_SPACES); + ut_ad(space == SRV_TMP_SPACE_ID + || space <= srv_undo_tablespaces_active + || !srv_was_started); return(space != SRV_TMP_SPACE_ID); } }; diff --git a/storage/innobase/include/trx0rseg.ic b/storage/innobase/include/trx0rseg.ic index 0a33c747668..45ee3ef8d66 100644 --- a/storage/innobase/include/trx0rseg.ic +++ b/storage/innobase/include/trx0rseg.ic @@ -42,7 +42,9 @@ trx_rsegf_get( buf_block_t* block; trx_rsegf_t* header; - ut_ad(space <= srv_undo_tablespaces || space == SRV_TMP_SPACE_ID); + ut_ad(space <= srv_undo_tablespaces_active || space == SRV_TMP_SPACE_ID + || !srv_was_started); + ut_ad(space <= TRX_SYS_MAX_UNDO_SPACES || space == SRV_TMP_SPACE_ID); block = buf_page_get( page_id_t(space, page_no), univ_page_size, RW_X_LATCH, mtr); @@ -69,7 +71,9 @@ trx_rsegf_get_new( buf_block_t* block; trx_rsegf_t* header; - ut_ad(space <= srv_undo_tablespaces || space == SRV_TMP_SPACE_ID); + ut_ad(space <= srv_undo_tablespaces_active || space == SRV_TMP_SPACE_ID + || !srv_was_started); + ut_ad(space <= TRX_SYS_MAX_UNDO_SPACES || space == SRV_TMP_SPACE_ID); block = buf_page_get( page_id_t(space, page_no), univ_page_size, RW_X_LATCH, mtr); diff --git a/storage/innobase/include/trx0sys.h b/storage/innobase/include/trx0sys.h index c361a9bac55..bf8cf2481eb 100644 --- a/storage/innobase/include/trx0sys.h +++ b/storage/innobase/include/trx0sys.h @@ -403,6 +403,8 @@ byte, therefore 128; each slot is currently 8 bytes in size. If you want to raise the level to 256 then you will need to fix some assertions that impose the 7 bit restriction. e.g., mach_write_to_3() */ #define TRX_SYS_N_RSEGS 128 +/** Maximum number of undo tablespaces (not counting the system tablespace) */ +#define TRX_SYS_MAX_UNDO_SPACES (TRX_SYS_N_RSEGS - 1) /** Maximum length of MySQL binlog file name, in bytes. */ #define TRX_SYS_MYSQL_LOG_NAME_LEN 512 diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc index 9e89dfda833..ef0d88b4316 100644 --- a/storage/innobase/srv/srv0start.cc +++ b/storage/innobase/srv/srv0start.cc @@ -121,22 +121,22 @@ lsn_t srv_start_lsn; lsn_t srv_shutdown_lsn; /** TRUE if a raw partition is in use */ -ibool srv_start_raw_disk_in_use = FALSE; +ibool srv_start_raw_disk_in_use; /** Number of IO threads to use */ -ulint srv_n_file_io_threads = 0; +ulint srv_n_file_io_threads; /** TRUE if the server is being started, before rolling back any incomplete transactions */ -bool srv_startup_is_before_trx_rollback_phase = false; +bool srv_startup_is_before_trx_rollback_phase; /** TRUE if the server is being started */ -bool srv_is_being_started = false; +bool srv_is_being_started; /** TRUE if SYS_TABLESPACES is available for lookups */ -bool srv_sys_tablespaces_open = false; +bool srv_sys_tablespaces_open; /** TRUE if the server was successfully started */ -ibool srv_was_started = FALSE; +bool srv_was_started; /** TRUE if innobase_start_or_create_for_mysql() has been called */ -static ibool srv_start_has_been_called = FALSE; +static bool srv_start_has_been_called; #ifdef UNIV_DEBUG /** InnoDB system tablespace to set during recovery */ UNIV_INTERN uint srv_sys_space_size_debug; @@ -1519,7 +1519,7 @@ innobase_start_or_create_for_mysql(void) " once during the process lifetime."; } - srv_start_has_been_called = TRUE; + srv_start_has_been_called = true; srv_is_being_started = true; @@ -2889,8 +2889,8 @@ innodb_shutdown() } srv_start_state = SRV_START_STATE_NONE; - srv_was_started = FALSE; - srv_start_has_been_called = FALSE; + srv_was_started = false; + srv_start_has_been_called = false; } #if 0 // TODO: Enable this in WL#6608 diff --git a/storage/innobase/trx/trx0sys.cc b/storage/innobase/trx/trx0sys.cc index 80aab87edaf..1ce9f49ba30 100644 --- a/storage/innobase/trx/trx0sys.cc +++ b/storage/innobase/trx/trx0sys.cc @@ -879,7 +879,7 @@ trx_sys_create_rsegs() srv_undo_logs determines how many of the srv_available_undo_logs rollback segments may be used for logging new transactions. */ - ut_ad(srv_undo_tablespaces < TRX_SYS_N_RSEGS); + ut_ad(srv_undo_tablespaces <= TRX_SYS_MAX_UNDO_SPACES); ut_ad(srv_undo_logs <= TRX_SYS_N_RSEGS); if (srv_read_only_mode) {