Skip to content

Commit

Permalink
Follow-up to MDEV-12289: Support innodb_undo_tablespaces=127
Browse files Browse the repository at this point in the history
MySQL 5.7 reduced the maximum number of innodb_undo_tablespaces
from 126 to 95 when it reserved 32 persistent rollback segments
for the temporary undo logs. Since MDEV-12289 restored all 128
persistent rollback segments for persistent undo logs, the
reasonable maximum value of innodb_undo_tablespaces is 127
(not 126 or 95). This is because out of the 128 rollback segments,
the first one will always be created in the system tablespace
and the remaining ones can be created in dedicated undo tablespaces.
  • Loading branch information
dr-m committed Apr 26, 2017
1 parent 23ea436 commit 206ecb7
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 23 deletions.
4 changes: 2 additions & 2 deletions mysql-test/suite/sys_vars/r/sysvars_innodb,32bit.rdiff
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions mysql-test/suite/sys_vars/r/sysvars_innodb.result
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions storage/innobase/handler/ha_innodb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4487,7 +4487,7 @@ innobase_init(
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();

Expand Down Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions storage/innobase/include/srv0srv.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 0 additions & 2 deletions storage/innobase/include/srv0start.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 4 additions & 1 deletion storage/innobase/include/trx0rseg.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
};
Expand Down
8 changes: 6 additions & 2 deletions storage/innobase/include/trx0rseg.ic
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions storage/innobase/include/trx0sys.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 10 additions & 10 deletions storage/innobase/srv/srv0start.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion storage/innobase/trx/trx0sys.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 206ecb7

Please sign in to comment.