Commit 44dce3b2 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-29986 Set innodb_undo_tablespaces=3 by default

Starting with commit baf276e6 (MDEV-19229)
the parameter innodb_undo_tablespaces can be increased from its
previous default value 0 while allowing an upgrade from old databases.

We will change the default setting to innodb_undo_tablespaces=3
so that the space occupied by possible bursts of undo log records
can be reclaimed after SET GLOBAL innodb_undo_log_truncate=ON.

We will not enable innodb_undo_log_truncate by default, because it
causes some observable performance degradation.

Special thanks to Thirunarayanan Balathandayuthapani for diagnosing
and fixing a number of bugs related to this new default setting.

Tested by: Matthias Leich, Axel Schwenke, Vladislav Vaintroub
(with both values of innodb_undo_log_truncate)
parent d6d85c92
...@@ -1667,7 +1667,7 @@ struct my_option xb_server_options[] = ...@@ -1667,7 +1667,7 @@ struct my_option xb_server_options[] =
{"innodb_undo_tablespaces", OPT_INNODB_UNDO_TABLESPACES, {"innodb_undo_tablespaces", OPT_INNODB_UNDO_TABLESPACES,
"Number of undo tablespaces to use.", "Number of undo tablespaces to use.",
(G_PTR*)&srv_undo_tablespaces, (G_PTR*)&srv_undo_tablespaces, (G_PTR*)&srv_undo_tablespaces, (G_PTR*)&srv_undo_tablespaces,
0, GET_UINT, REQUIRED_ARG, 0, 0, 126, 0, 1, 0}, 0, GET_UINT, REQUIRED_ARG, 3, 0, 126, 0, 1, 0},
{"innodb_compression_level", OPT_INNODB_COMPRESSION_LEVEL, {"innodb_compression_level", OPT_INNODB_COMPRESSION_LEVEL,
"Compression level used for zlib compression.", "Compression level used for zlib compression.",
......
...@@ -38,6 +38,9 @@ INSERT INTO t2 values(1, 'secret', ST_GeomFromText('POINT(903994614 180726515)') ...@@ -38,6 +38,9 @@ INSERT INTO t2 values(1, 'secret', ST_GeomFromText('POINT(903994614 180726515)')
SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION > 0; SELECT NAME FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION > 0;
NAME NAME
innodb_system innodb_system
innodb_undo001
innodb_undo002
innodb_undo003
mysql/innodb_index_stats mysql/innodb_index_stats
mysql/innodb_table_stats mysql/innodb_table_stats
mysql/transaction_registry mysql/transaction_registry
......
...@@ -10,7 +10,7 @@ TABLE_ID NAME FLAG N_COLS SPACE ROW_FORMAT ZIP_PAGE_SIZE SPACE_TYPE ...@@ -10,7 +10,7 @@ TABLE_ID NAME FLAG N_COLS SPACE ROW_FORMAT ZIP_PAGE_SIZE SPACE_TYPE
11 SYS_FOREIGN 0 7 0 Redundant 0 System 11 SYS_FOREIGN 0 7 0 Redundant 0 System
12 SYS_FOREIGN_COLS 0 7 0 Redundant 0 System 12 SYS_FOREIGN_COLS 0 7 0 Redundant 0 System
13 SYS_VIRTUAL 0 6 0 Redundant 0 System 13 SYS_VIRTUAL 0 6 0 Redundant 0 System
16 mysql/transaction_registry 33 8 3 Dynamic 0 Single 16 mysql/transaction_registry 33 8 6 Dynamic 0 Single
SELECT table_id,pos,mtype,prtype,len,name SELECT table_id,pos,mtype,prtype,len,name
FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS
WHERE table_id NOT IN (@table_stats_id, @index_stats_id) WHERE table_id NOT IN (@table_stats_id, @index_stats_id)
......
...@@ -10,10 +10,20 @@ call mtr.add_suppression("Plugin 'InnoDB' registration as a STORAGE ENGINE faile ...@@ -10,10 +10,20 @@ call mtr.add_suppression("Plugin 'InnoDB' registration as a STORAGE ENGINE faile
--let $MYSQLD_DATADIR=`SELECT @@datadir` --let $MYSQLD_DATADIR=`SELECT @@datadir`
--let $DATA= $MYSQLD_DATADIR/ibdata1 --let $DATA= $MYSQLD_DATADIR/ibdata1
--let $DATACOPY=$MYSQLTEST_VARDIR/tmp/ibdata1 --let $DATACOPY=$MYSQLTEST_VARDIR/tmp/ibdata1
--let $UNDO_1= $MYSQLD_DATADIR/undo001
--let $UNDO_2= $MYSQLD_DATADIR/undo002
--let $UNDO_3= $MYSQLD_DATADIR/undo003
--let $UNDO_1_COPY=$MYSQLTEST_VARDIR/tmp/undo001
--let $UNDO_2_COPY=$MYSQLTEST_VARDIR/tmp/undo002
--let $UNDO_3_COPY=$MYSQLTEST_VARDIR/tmp/undo003
CREATE TABLE t(a INT) ENGINE=InnoDB; CREATE TABLE t(a INT) ENGINE=InnoDB;
--source include/kill_mysqld.inc --source include/kill_mysqld.inc
# Move the file to cause srv_init_abort_low() call from srv_start() # Move the file to cause srv_init_abort_low() call from srv_start()
--move_file $DATA $DATACOPY --move_file $DATA $DATACOPY
--move_file $UNDO_1 $UNDO_1_COPY
--move_file $UNDO_2 $UNDO_2_COPY
--move_file $UNDO_3 $UNDO_3_COPY
# If the bug is not fixed, the server will hang here. Note that the test is # If the bug is not fixed, the server will hang here. Note that the test is
# unstable because the condition # unstable because the condition
...@@ -28,5 +38,8 @@ CREATE TABLE t(a INT) ENGINE=InnoDB; ...@@ -28,5 +38,8 @@ CREATE TABLE t(a INT) ENGINE=InnoDB;
SELECT * FROM t; SELECT * FROM t;
--source include/kill_mysqld.inc --source include/kill_mysqld.inc
--move_file $DATACOPY $DATA --move_file $DATACOPY $DATA
--move_file $UNDO_1_COPY $UNDO_1
--move_file $UNDO_2_COPY $UNDO_2
--move_file $UNDO_3_COPY $UNDO_3
--source include/start_mysqld.inc --source include/start_mysqld.inc
DROP TABLE t; DROP TABLE t;
--loose-innodb-sys-indexes --loose-innodb-sys-indexes
--innodb-data-file-path=ibdata1:1M:autoextend --innodb-data-file-path=ibdata1:1M:autoextend
--innodb-undo-tablespaces=0
--innodb-checksum-algorithm=crc32 --innodb-checksum-algorithm=crc32
--innodb-undo-tablespaces=0
--innodb-checksum-algorithm=crc32 --innodb-checksum-algorithm=crc32
--skip-innodb-read-only-compressed --innodb-undo-tablespaces=0
...@@ -1653,7 +1653,7 @@ READ_ONLY NO ...@@ -1653,7 +1653,7 @@ READ_ONLY NO
COMMAND_LINE_ARGUMENT OPTIONAL COMMAND_LINE_ARGUMENT OPTIONAL
VARIABLE_NAME INNODB_UNDO_TABLESPACES VARIABLE_NAME INNODB_UNDO_TABLESPACES
SESSION_VALUE NULL SESSION_VALUE NULL
DEFAULT_VALUE 0 DEFAULT_VALUE 3
VARIABLE_SCOPE GLOBAL VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE INT UNSIGNED VARIABLE_TYPE INT UNSIGNED
VARIABLE_COMMENT Number of undo tablespaces to use. VARIABLE_COMMENT Number of undo tablespaces to use.
......
...@@ -33,7 +33,7 @@ let $restart_parameters=$default_parameters --innodb_encryption_threads=5 --inno ...@@ -33,7 +33,7 @@ let $restart_parameters=$default_parameters --innodb_encryption_threads=5 --inno
--echo # Wait until encryption threads have encrypted all tablespaces --echo # Wait until encryption threads have encrypted all tablespaces
--let $tables_count= `select count(*) + 1 from information_schema.tables where engine = 'InnoDB'` --let $tables_count= `select count(*) + 1 + @@global.innodb_undo_tablespaces from information_schema.tables where engine = 'InnoDB'`
--let $wait_timeout= 600 --let $wait_timeout= 600
--let $wait_condition=SELECT COUNT(*) >= $tables_count FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; --let $wait_condition=SELECT COUNT(*) >= $tables_count FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0;
--source include/wait_condition.inc --source include/wait_condition.inc
...@@ -63,7 +63,7 @@ alter table t33 encryption_key_id=222; ...@@ -63,7 +63,7 @@ alter table t33 encryption_key_id=222;
--echo # Wait until encryption threads have encrypted all tablespaces --echo # Wait until encryption threads have encrypted all tablespaces
--let $tables_count= `select count(*) from information_schema.tables where engine = 'InnoDB'` --let $tables_count= `select count(*) + @@global.innodb_undo_tablespaces from information_schema.tables where engine = 'InnoDB'`
--let $wait_timeout= 600 --let $wait_timeout= 600
--let $wait_condition=SELECT COUNT(*) >= $tables_count FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; --let $wait_condition=SELECT COUNT(*) >= $tables_count FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0;
--source include/wait_condition.inc --source include/wait_condition.inc
...@@ -77,7 +77,7 @@ set global innodb_encrypt_tables = OFF; ...@@ -77,7 +77,7 @@ set global innodb_encrypt_tables = OFF;
--echo # Wait until encryption threads to decrypt all encrypted tablespaces --echo # Wait until encryption threads to decrypt all encrypted tablespaces
--let $tables_count= `select count(*) - 1 from information_schema.tables where engine = 'InnoDB'` --let $tables_count= `select count(*) - 1 + @@global.innodb_undo_tablespaces from information_schema.tables where engine = 'InnoDB'`
--let $wait_timeout= 600 --let $wait_timeout= 600
--let $wait_condition=SELECT COUNT(*) >= $tables_count FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND ROTATING_OR_FLUSHING = 0; --let $wait_condition=SELECT COUNT(*) >= $tables_count FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION = 0 AND ROTATING_OR_FLUSHING = 0;
--source include/wait_condition.inc --source include/wait_condition.inc
...@@ -105,7 +105,7 @@ set global innodb_encrypt_tables = ON; ...@@ -105,7 +105,7 @@ set global innodb_encrypt_tables = ON;
--echo # Wait until encryption threads to encrypt all unencrypted tablespaces --echo # Wait until encryption threads to encrypt all unencrypted tablespaces
--let $tables_count= `select count(*) from information_schema.tables where engine = 'InnoDB'` --let $tables_count= `select count(*) + @@global.innodb_undo_tablespaces from information_schema.tables where engine = 'InnoDB'`
--let $wait_timeout= 600 --let $wait_timeout= 600
--let $wait_condition=SELECT COUNT(*) >= $tables_count FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0; --let $wait_condition=SELECT COUNT(*) >= $tables_count FROM INFORMATION_SCHEMA.INNODB_TABLESPACES_ENCRYPTION WHERE MIN_KEY_VERSION <> 0;
--source include/wait_condition.inc --source include/wait_condition.inc
......
...@@ -588,7 +588,7 @@ bool buf_page_is_corrupted(bool check_lsn, const byte *read_buf, ...@@ -588,7 +588,7 @@ bool buf_page_is_corrupted(bool check_lsn, const byte *read_buf,
DBUG_EXECUTE_IF( DBUG_EXECUTE_IF(
"page_intermittent_checksum_mismatch", { "page_intermittent_checksum_mismatch", {
static int page_counter; static int page_counter;
if (page_counter++ == 3) { if (page_counter++ == 6) {
crc32++; crc32++;
} }
}); });
...@@ -723,7 +723,8 @@ bool buf_page_is_corrupted(bool check_lsn, const byte *read_buf, ...@@ -723,7 +723,8 @@ bool buf_page_is_corrupted(bool check_lsn, const byte *read_buf,
DBUG_EXECUTE_IF( DBUG_EXECUTE_IF(
"page_intermittent_checksum_mismatch", { "page_intermittent_checksum_mismatch", {
static int page_counter; static int page_counter;
if (page_counter++ == 3) return true; if (page_counter++ == 6)
return true;
}); });
if ((checksum_field1 != crc32 if ((checksum_field1 != crc32
......
...@@ -19345,7 +19345,7 @@ static MYSQL_SYSVAR_UINT(undo_tablespaces, srv_undo_tablespaces, ...@@ -19345,7 +19345,7 @@ static MYSQL_SYSVAR_UINT(undo_tablespaces, srv_undo_tablespaces,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"Number of undo tablespaces to use.", "Number of undo tablespaces to use.",
NULL, NULL, NULL, NULL,
0L, /* Default seting */ 3L, /* Default seting */
0L, /* Minimum value */ 0L, /* Minimum value */
TRX_SYS_MAX_UNDO_SPACES, 0); /* Maximum value */ TRX_SYS_MAX_UNDO_SPACES, 0); /* Maximum value */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment