Skip to content

Commit 206ecb7

Browse files
committed
Follow-up to MDEV-12289: Support innodb_undo_tablespaces=127
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.
1 parent 23ea436 commit 206ecb7

File tree

10 files changed

+33
-23
lines changed

10 files changed

+33
-23
lines changed

mysql-test/suite/sys_vars/r/sysvars_innodb,32bit.rdiff

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -571,9 +571,9 @@
571571
VARIABLE_SCOPE GLOBAL
572572
-VARIABLE_TYPE BIGINT UNSIGNED
573573
+VARIABLE_TYPE INT UNSIGNED
574-
VARIABLE_COMMENT Number of undo tablespaces to use.
574+
VARIABLE_COMMENT Number of undo tablespaces to use.
575575
NUMERIC_MIN_VALUE 0
576-
NUMERIC_MAX_VALUE95
576+
NUMERIC_MAX_VALUE127
577577
@@ -2630,7 +2630,7 @@
578578
GLOBAL_VALUE_ORIGIN CONFIG
579579
DEFAULT_VALUE 4

mysql-test/suite/sys_vars/r/sysvars_innodb.result

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2505,9 +2505,9 @@ GLOBAL_VALUE_ORIGIN COMPILE-TIME
25052505
DEFAULT_VALUE 0
25062506
VARIABLE_SCOPE GLOBAL
25072507
VARIABLE_TYPE BIGINT UNSIGNED
2508-
VARIABLE_COMMENT Number of undo tablespaces to use.
2508+
VARIABLE_COMMENT Number of undo tablespaces to use.
25092509
NUMERIC_MIN_VALUE 0
2510-
NUMERIC_MAX_VALUE95
2510+
NUMERIC_MAX_VALUE127
25112511
NUMERIC_BLOCK_SIZE 0
25122512
ENUM_VALUE_LIST NULL
25132513
READ_ONLY YES

storage/innobase/handler/ha_innodb.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4487,7 +4487,7 @@ innobase_init(
44874487
os_thread_sleep(20);
44884488
}
44894489

4490-
srv_was_started = TRUE;
4490+
srv_was_started = true;
44914491
/* Adjust the innodb_undo_logs config object */
44924492
innobase_undo_logs_init_default_max();
44934493

@@ -21477,11 +21477,11 @@ static MYSQL_SYSVAR_STR(undo_directory, srv_undo_dir,
2147721477

2147821478
static MYSQL_SYSVAR_ULONG(undo_tablespaces, srv_undo_tablespaces,
2147921479
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
21480-
"Number of undo tablespaces to use. ",
21480+
"Number of undo tablespaces to use.",
2148121481
NULL, NULL,
2148221482
0L, /* Default seting */
2148321483
0L, /* Minimum value */
21484-
95L, 0);/* Maximum value */
21484+
TRX_SYS_MAX_UNDO_SPACES, 0); /* Maximum value */
2148521485

2148621486
static MYSQL_SYSVAR_ULONG(undo_logs, srv_undo_logs,
2148721487
PLUGIN_VAR_OPCMDARG,

storage/innobase/include/srv0srv.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,9 @@ extern long srv_mtflush_threads;
301301
/* If this flag is TRUE, then we will use multi threaded flush. */
302302
extern my_boolsrv_use_mtflush;
303303

304+
/** TRUE if the server was successfully started */
305+
extern boolsrv_was_started;
306+
304307
/** Server undo tablespaces directory, can be absolute path. */
305308
extern char*srv_undo_dir;
306309

storage/innobase/include/srv0start.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,6 @@ extern lsn_t srv_start_lsn;
121121
externboolsrv_is_being_started;
122122
/** TRUE if SYS_TABLESPACES is available for lookups */
123123
externboolsrv_sys_tablespaces_open;
124-
/** TRUE if the server was successfully started */
125-
externiboolsrv_was_started;
126124
/** TRUE if the server is being started, before rolling back any
127125
incomplete transactions */
128126
externboolsrv_startup_is_before_trx_rollback_phase;

storage/innobase/include/trx0rseg.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,10 @@ struct trx_rseg_t {
200200
bool is_persistent() const
201201
{
202202
ut_ad(space == SRV_TMP_SPACE_ID
203-
|| space <= srv_undo_tablespaces);
203+
|| space <= TRX_SYS_MAX_UNDO_SPACES);
204+
ut_ad(space == SRV_TMP_SPACE_ID
205+
|| space <= srv_undo_tablespaces_active
206+
|| !srv_was_started);
204207
return(space != SRV_TMP_SPACE_ID);
205208
}
206209
};

storage/innobase/include/trx0rseg.ic

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ trx_rsegf_get(
4242
buf_block_t* block;
4343
trx_rsegf_t* header;
4444

45-
ut_ad(space <= srv_undo_tablespaces || space == SRV_TMP_SPACE_ID);
45+
ut_ad(space <= srv_undo_tablespaces_active || space == SRV_TMP_SPACE_ID
46+
|| !srv_was_started);
47+
ut_ad(space <= TRX_SYS_MAX_UNDO_SPACES || space == SRV_TMP_SPACE_ID);
4648

4749
block = buf_page_get(
4850
page_id_t(space, page_no), univ_page_size, RW_X_LATCH, mtr);
@@ -69,7 +71,9 @@ trx_rsegf_get_new(
6971
buf_block_t* block;
7072
trx_rsegf_t* header;
7173

72-
ut_ad(space <= srv_undo_tablespaces || space == SRV_TMP_SPACE_ID);
74+
ut_ad(space <= srv_undo_tablespaces_active || space == SRV_TMP_SPACE_ID
75+
|| !srv_was_started);
76+
ut_ad(space <= TRX_SYS_MAX_UNDO_SPACES || space == SRV_TMP_SPACE_ID);
7377

7478
block = buf_page_get(
7579
page_id_t(space, page_no), univ_page_size, RW_X_LATCH, mtr);

storage/innobase/include/trx0sys.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,8 @@ byte, therefore 128; each slot is currently 8 bytes in size. If you want
403403
to raise the level to 256 then you will need to fix some assertions that
404404
impose the 7 bit restriction. e.g., mach_write_to_3() */
405405
#defineTRX_SYS_N_RSEGS128
406+
/** Maximum number of undo tablespaces (not counting the system tablespace) */
407+
#define TRX_SYS_MAX_UNDO_SPACES(TRX_SYS_N_RSEGS - 1)
406408

407409
/** Maximum length of MySQL binlog file name, in bytes. */
408410
#define TRX_SYS_MYSQL_LOG_NAME_LEN512

storage/innobase/srv/srv0start.cc

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -121,22 +121,22 @@ lsn_t srv_start_lsn;
121121
lsn_tsrv_shutdown_lsn;
122122

123123
/** TRUE if a raw partition is in use */
124-
ibool srv_start_raw_disk_in_use = FALSE;
124+
ibool srv_start_raw_disk_in_use;
125125

126126
/** Number of IO threads to use */
127-
ulint srv_n_file_io_threads = 0;
127+
ulint srv_n_file_io_threads;
128128

129129
/** TRUE if the server is being started, before rolling back any
130130
incomplete transactions */
131-
boolsrv_startup_is_before_trx_rollback_phase = false;
131+
boolsrv_startup_is_before_trx_rollback_phase;
132132
/** TRUE if the server is being started */
133-
boolsrv_is_being_started = false;
133+
boolsrv_is_being_started;
134134
/** TRUE if SYS_TABLESPACES is available for lookups */
135-
boolsrv_sys_tablespaces_open = false;
135+
boolsrv_sys_tablespaces_open;
136136
/** TRUE if the server was successfully started */
137-
iboolsrv_was_started = FALSE;
137+
boolsrv_was_started;
138138
/** TRUE if innobase_start_or_create_for_mysql() has been called */
139-
static iboolsrv_start_has_been_called = FALSE;
139+
static boolsrv_start_has_been_called;
140140
#ifdef UNIV_DEBUG
141141
/** InnoDB system tablespace to set during recovery */
142142
UNIV_INTERN uint srv_sys_space_size_debug;
@@ -1519,7 +1519,7 @@ innobase_start_or_create_for_mysql(void)
15191519
" once during the process lifetime.";
15201520
}
15211521

1522-
srv_start_has_been_called = TRUE;
1522+
srv_start_has_been_called = true;
15231523

15241524
srv_is_being_started = true;
15251525

@@ -2889,8 +2889,8 @@ innodb_shutdown()
28892889
}
28902890

28912891
srv_start_state = SRV_START_STATE_NONE;
2892-
srv_was_started = FALSE;
2893-
srv_start_has_been_called = FALSE;
2892+
srv_was_started = false;
2893+
srv_start_has_been_called = false;
28942894
}
28952895

28962896
#if 0 // TODO: Enable this in WL#6608

storage/innobase/trx/trx0sys.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -879,7 +879,7 @@ trx_sys_create_rsegs()
879879
srv_undo_logs determines how many of the
880880
srv_available_undo_logs rollback segments may be used for
881881
logging new transactions. */
882-
ut_ad(srv_undo_tablespaces < TRX_SYS_N_RSEGS);
882+
ut_ad(srv_undo_tablespaces <= TRX_SYS_MAX_UNDO_SPACES);
883883
ut_ad(srv_undo_logs <= TRX_SYS_N_RSEGS);
884884

885885
if (srv_read_only_mode) {

0 commit comments

Comments
 (0)