Commit 893472d0 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-19570 Deprecate and ignore innodb_undo_logs, remove innodb_rollback_segments

The option innodb_rollback_segments was deprecated already in
MariaDB Server 10.0. Its misleadingly named replacement innodb_undo_logs
is of very limited use. It makes sense to always create and use the
maximum number of rollback segments.

Let us remove the deprecated parameter innodb_rollback_segments and
deprecate&ignore the parameter innodb_undo_logs (to be removed in a
later major release).

This work involves some cleanup of InnoDB startup. Similar to other
write operations, DROP TABLE will no longer be allowed if
innodb_force_recovery is set to a value larger than 3.
parent c8301875
......@@ -5441,7 +5441,6 @@ static bool xtrabackup_prepare_func(char** argv)
}
srv_max_n_threads = 1000;
srv_undo_logs = 1;
srv_n_purge_threads = 1;
xb_filters_init();
......
call mtr.add_suppression("InnoDB: Warning: cannot find a free slot for an undo log. Do you have too*");
call mtr.add_suppression("\\[Warning\\] InnoDB: Cannot find a free slot for an undo log. Do you have too");
set @old_innodb_undo_logs = @@innodb_undo_logs;
set global innodb_undo_logs=1;
show variables like "max_connections";
Variable_name Value
max_connections 64
......@@ -28,4 +26,3 @@ select count(*) from information_schema.processlist where command != 'Daemon';
count(*)
33
drop database mysqltest;
set global innodb_undo_logs = @old_innodb_undo_logs;
......@@ -29,8 +29,10 @@ ERROR HY000: Error on rename of './test/t1' to './test/t3' (errno: 165 "Table is
truncate table t1;
ERROR HY000: Table 't1' is read only
drop table t1;
ERROR HY000: Table 't1' is read only
show tables;
Tables_in_test
t1
t2
# Restart the server with innodb_force_recovery as 5.
# restart: --innodb-force-recovery=5
......@@ -47,10 +49,10 @@ drop index idx on t2;
ERROR HY000: Can't create table `test`.`t2` (errno: 165 "Table is read only")
update t2 set f1=3 where f2=2;
ERROR HY000: Running in read-only mode
create table t1(f1 int not null)engine=innodb;
ERROR HY000: Can't create table `test`.`t1` (errno: 165 "Table is read only")
drop table t1;
ERROR 42S02: Unknown table 'test.t1'
create table t3(f1 int not null)engine=innodb;
ERROR HY000: Can't create table `test`.`t3` (errno: 165 "Table is read only")
drop table t3;
ERROR 42S02: Unknown table 'test.t3'
rename table t2 to t3;
ERROR HY000: Error on rename of './test/t2' to './test/t3' (errno: 165 "Table is read only")
truncate table t2;
......@@ -59,6 +61,7 @@ drop table t2;
ERROR HY000: Table 't2' is read only
show tables;
Tables_in_test
t1
t2
# Restart the server with innodb_force_recovery as 6.
# restart: --innodb-force-recovery=6
......@@ -75,10 +78,10 @@ drop index idx on t2;
ERROR HY000: Table 't2' is read only
update t2 set f1=3 where f2=2;
ERROR HY000: Table 't2' is read only
create table t1(f1 int not null)engine=innodb;
ERROR HY000: Can't create table `test`.`t1` (errno: 165 "Table is read only")
create table t3(f1 int not null)engine=innodb;
ERROR HY000: Can't create table `test`.`t3` (errno: 165 "Table is read only")
drop table t1;
ERROR 42S02: Unknown table 'test.t1'
ERROR HY000: Table 't1' is read only
rename table t2 to t3;
ERROR HY000: Error on rename of './test/t2' to './test/t3' (errno: 165 "Table is read only")
truncate table t2;
......@@ -87,6 +90,7 @@ drop table t2;
ERROR HY000: Table 't2' is read only
show tables;
Tables_in_test
t1
t2
# Restart the server with innodb_force_recovery=2
# restart: --innodb-force-recovery=2
......@@ -96,10 +100,9 @@ f1 f2
begin;
update t2 set f2=3;
connect con1,localhost,root,,;
create table t3(a int)engine=innodb;
# Force a redo log flush of the above uncommitted UPDATE
SET GLOBAL innodb_flush_log_at_trx_commit=1;
drop table t3;
drop table t1;
disconnect con1;
connection default;
# Kill the server
......
SET @save_undo_logs = @@GLOBAL.innodb_undo_logs;
SET @save_frequency = @@GLOBAL.innodb_purge_rseg_truncate_frequency;
SET @save_truncate = @@GLOBAL.innodb_undo_log_truncate;
SET GLOBAL innodb_undo_log_truncate = 0;
SET GLOBAL innodb_undo_logs = 4;
SET GLOBAL innodb_purge_rseg_truncate_frequency = 1;
SET @trunc_start=
(SELECT variable_value FROM information_schema.global_status
......@@ -55,6 +53,5 @@ drop table t1, t2;
drop PROCEDURE populate_t1;
drop PROCEDURE populate_t2;
InnoDB 0 transactions not purged
SET GLOBAL innodb_undo_logs = @save_undo_logs;
SET GLOBAL innodb_purge_rseg_truncate_frequency = @save_frequency;
SET GLOBAL innodb_undo_log_truncate = @save_truncate;
SET GLOBAL innodb_undo_logs = 4;
SET GLOBAL innodb_undo_log_truncate = 1;
SET GLOBAL innodb_purge_rseg_truncate_frequency = 1;
create table t1(keyc int primary key, c char(100)) engine = innodb;
......
--max_connections=64 --innodb_thread_concurrency=0 --innodb_file_per_table --innodb_rollback_segments=2
--max_connections=64 --innodb_thread_concurrency=0
......@@ -18,9 +18,6 @@ set @old_innodb_trx_rseg_n_slots_debug = @@innodb_trx_rseg_n_slots_debug;
set global innodb_trx_rseg_n_slots_debug = 32;
--enable_query_log
set @old_innodb_undo_logs = @@innodb_undo_logs;
set global innodb_undo_logs=1;
show variables like "max_connections";
show variables like "innodb_thread_concurrency";
show variables like "innodb_file_per_table";
......@@ -105,8 +102,6 @@ while ($c)
#
drop database mysqltest;
set global innodb_undo_logs = @old_innodb_undo_logs;
--disable_query_log
set global innodb_trx_rseg_n_slots_debug = @old_innodb_trx_rseg_n_slots_debug;
--enable_query_log
......@@ -52,6 +52,7 @@ rename table t1 to t3;
--error ER_OPEN_AS_READONLY
truncate table t1;
--error ER_OPEN_AS_READONLY
drop table t1;
show tables;
......@@ -77,10 +78,10 @@ drop index idx on t2;
update t2 set f1=3 where f2=2;
--error ER_CANT_CREATE_TABLE
create table t1(f1 int not null)engine=innodb;
create table t3(f1 int not null)engine=innodb;
--error ER_BAD_TABLE_ERROR
drop table t1;
drop table t3;
--error ER_ERROR_ON_RENAME
rename table t2 to t3;
......@@ -114,9 +115,9 @@ drop index idx on t2;
update t2 set f1=3 where f2=2;
--error ER_CANT_CREATE_TABLE
create table t1(f1 int not null)engine=innodb;
create table t3(f1 int not null)engine=innodb;
--error ER_BAD_TABLE_ERROR
--error ER_OPEN_AS_READONLY
drop table t1;
--error ER_ERROR_ON_RENAME
......@@ -138,10 +139,9 @@ begin;
update t2 set f2=3;
connect (con1,localhost,root,,);
create table t3(a int)engine=innodb;
--echo # Force a redo log flush of the above uncommitted UPDATE
SET GLOBAL innodb_flush_log_at_trx_commit=1;
drop table t3;
drop table t1;
disconnect con1;
connection default;
......
......@@ -2,11 +2,9 @@
--source include/innodb_page_size.inc
--source include/have_undo_tablespaces.inc
SET @save_undo_logs = @@GLOBAL.innodb_undo_logs;
SET @save_frequency = @@GLOBAL.innodb_purge_rseg_truncate_frequency;
SET @save_truncate = @@GLOBAL.innodb_undo_log_truncate;
SET GLOBAL innodb_undo_log_truncate = 0;
SET GLOBAL innodb_undo_logs = 4;
SET GLOBAL innodb_purge_rseg_truncate_frequency = 1;
SET @trunc_start=
......@@ -117,6 +115,5 @@ if ($size1 == $size2)
}
}
SET GLOBAL innodb_undo_logs = @save_undo_logs;
SET GLOBAL innodb_purge_rseg_truncate_frequency = @save_frequency;
SET GLOBAL innodb_undo_log_truncate = @save_truncate;
......@@ -11,7 +11,6 @@
# Tests with embedded server do not support restarting
--source include/not_embedded.inc
SET GLOBAL innodb_undo_logs = 4;
SET GLOBAL innodb_undo_log_truncate = 1;
SET GLOBAL innodb_purge_rseg_truncate_frequency = 1;
......
SET @start_global_value = @@global.innodb_rollback_segments;
SELECT @start_global_value;
@start_global_value
128
Valid values are zero or above
SELECT @@global.innodb_rollback_segments >=0;
@@global.innodb_rollback_segments >=0
1
SELECT @@global.innodb_rollback_segments <=128;
@@global.innodb_rollback_segments <=128
1
SELECT @@global.innodb_rollback_segments;
@@global.innodb_rollback_segments
128
SELECT @@session.innodb_rollback_segments;
ERROR HY000: Variable 'innodb_rollback_segments' is a GLOBAL variable
SHOW global variables LIKE 'innodb_rollback_segments';
Variable_name Value
innodb_rollback_segments 128
SHOW session variables LIKE 'innodb_rollback_segments';
Variable_name Value
innodb_rollback_segments 128
SELECT * FROM information_schema.global_variables
WHERE variable_name='innodb_rollback_segments';
VARIABLE_NAME VARIABLE_VALUE
INNODB_ROLLBACK_SEGMENTS 128
SELECT * FROM information_schema.session_variables
WHERE variable_name='innodb_rollback_segments';
VARIABLE_NAME VARIABLE_VALUE
INNODB_ROLLBACK_SEGMENTS 128
SET global innodb_rollback_segments=100;
SELECT @@global.innodb_rollback_segments;
@@global.innodb_rollback_segments
100
SELECT * FROM information_schema.global_variables
WHERE variable_name='innodb_rollback_segments';
VARIABLE_NAME VARIABLE_VALUE
INNODB_ROLLBACK_SEGMENTS 100
SELECT * FROM information_schema.session_variables
WHERE variable_name='innodb_rollback_segments';
VARIABLE_NAME VARIABLE_VALUE
INNODB_ROLLBACK_SEGMENTS 100
SET session innodb_rollback_segments=1;
ERROR HY000: Variable 'innodb_rollback_segments' is a GLOBAL variable and should be set with SET GLOBAL
SET global innodb_rollback_segments=1.1;
ERROR 42000: Incorrect argument type to variable 'innodb_rollback_segments'
SET global innodb_rollback_segments=1e1;
ERROR 42000: Incorrect argument type to variable 'innodb_rollback_segments'
SET global innodb_rollback_segments="foo";
ERROR 42000: Incorrect argument type to variable 'innodb_rollback_segments'
SET global innodb_rollback_segments=-7;
Warnings:
Warning 1292 Truncated incorrect innodb_rollback_segments value: '-7'
SELECT @@global.innodb_rollback_segments;
@@global.innodb_rollback_segments
1
SELECT * FROM information_schema.global_variables
WHERE variable_name='innodb_rollback_segments';
VARIABLE_NAME VARIABLE_VALUE
INNODB_ROLLBACK_SEGMENTS 1
SET @@global.innodb_rollback_segments = @start_global_value;
SELECT @@global.innodb_rollback_segments;
@@global.innodb_rollback_segments
128
SELECT @@GLOBAL.innodb_undo_logs;
@@GLOBAL.innodb_undo_logs
SELECT @@global.innodb_undo_logs;
@@global.innodb_undo_logs
128
128 Expected
SET @@GLOBAL.innodb_undo_logs=128;
SELECT COUNT(@@GLOBAL.innodb_undo_logs);
COUNT(@@GLOBAL.innodb_undo_logs)
1
1 Expected
SELECT VARIABLE_VALUE
FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
WHERE VARIABLE_NAME='innodb_undo_logs';
VARIABLE_VALUE
128
128 Expected
SELECT @@innodb_undo_logs = @@GLOBAL.innodb_undo_logs;
@@innodb_undo_logs = @@GLOBAL.innodb_undo_logs
1
1 Expected
SELECT COUNT(@@innodb_undo_logs);
COUNT(@@innodb_undo_logs)
1
1 Expected
SELECT COUNT(@@local.innodb_undo_logs);
ERROR HY000: Variable 'innodb_undo_logs' is a GLOBAL variable
Expected error 'Variable is a GLOBAL variable'
SELECT COUNT(@@SESSION.innodb_undo_logs);
SELECT @@session.innodb_undo_logs;
ERROR HY000: Variable 'innodb_undo_logs' is a GLOBAL variable
Expected error 'Variable is a GLOBAL variable'
SELECT innodb_undo_logs = @@SESSION.innodb_undo_logs;
ERROR 42S22: Unknown column 'innodb_undo_logs' in 'field list'
Begin bug 13604034
select @@innodb_undo_logs;
@@innodb_undo_logs
128
128 Expected
set global innodb_undo_logs = 129;
SHOW global variables LIKE 'innodb_undo_logs';
Variable_name Value
innodb_undo_logs 128
SHOW session variables LIKE 'innodb_undo_logs';
Variable_name Value
innodb_undo_logs 128
SELECT * FROM information_schema.global_variables
WHERE variable_name='innodb_undo_logs';
VARIABLE_NAME VARIABLE_VALUE
INNODB_UNDO_LOGS 128
SELECT * FROM information_schema.session_variables
WHERE variable_name='innodb_undo_logs';
VARIABLE_NAME VARIABLE_VALUE
INNODB_UNDO_LOGS 128
SET global innodb_undo_logs=100;
Warnings:
Warning 1292 Truncated incorrect innodb_undo_logs value: '129'
select @@innodb_undo_logs;
@@innodb_undo_logs
Warning 138 The parameter innodb_undo_logs is deprecated and has no effect.
SELECT @@global.innodb_undo_logs;
@@global.innodb_undo_logs
128
128 Expected
set global innodb_undo_logs = 0;
Warnings:
Warning 1292 Truncated incorrect innodb_undo_logs value: '0'
select @@innodb_undo_logs;
@@innodb_undo_logs
1
1 Expected
set global innodb_undo_logs = -1;
SET session innodb_undo_logs=1;
ERROR HY000: Variable 'innodb_undo_logs' is a GLOBAL variable and should be set with SET GLOBAL
SET global innodb_undo_logs=1.1;
ERROR 42000: Incorrect argument type to variable 'innodb_undo_logs'
SET global innodb_undo_logs=1e1;
ERROR 42000: Incorrect argument type to variable 'innodb_undo_logs'
SET global innodb_undo_logs="foo";
ERROR 42000: Incorrect argument type to variable 'innodb_undo_logs'
SET global innodb_undo_logs=-7;
Warnings:
Warning 1292 Truncated incorrect innodb_undo_logs value: '-1'
select @@innodb_undo_logs;
@@innodb_undo_logs
1
1 Expected
set global innodb_undo_logs = 50;
select @@innodb_undo_logs;
@@innodb_undo_logs
50
50 Expected
set global innodb_undo_logs = default;
select @@innodb_undo_logs;
@@innodb_undo_logs
Warning 1292 Truncated incorrect innodb_undo_logs value: '-7'
Warning 138 The parameter innodb_undo_logs is deprecated and has no effect.
SELECT @@global.innodb_undo_logs;
@@global.innodb_undo_logs
128
128 Expected
End bug 13604034
SELECT * FROM information_schema.global_variables
WHERE variable_name='innodb_undo_logs';
VARIABLE_NAME VARIABLE_VALUE
INNODB_UNDO_LOGS 128
......@@ -457,15 +457,6 @@
NUMERIC_BLOCK_SIZE 0
ENUM_VALUE_LIST NULL
READ_ONLY NO
@@ -1932,7 +1932,7 @@
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 128
VARIABLE_SCOPE GLOBAL
-VARIABLE_TYPE BIGINT UNSIGNED
+VARIABLE_TYPE INT UNSIGNED
VARIABLE_COMMENT Number of undo logs to use (deprecated).
NUMERIC_MIN_VALUE 1
NUMERIC_MAX_VALUE 128
@@ -1946,7 +1946,7 @@
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 0
......@@ -530,7 +521,7 @@
VARIABLE_SCOPE GLOBAL
-VARIABLE_TYPE BIGINT UNSIGNED
+VARIABLE_TYPE INT UNSIGNED
VARIABLE_COMMENT Number of undo logs to use.
VARIABLE_COMMENT Deprecated parameter with no effect.
NUMERIC_MIN_VALUE 1
NUMERIC_MAX_VALUE 128
@@ -2394,7 +2394,7 @@
......
......@@ -1926,20 +1926,6 @@ NUMERIC_BLOCK_SIZE NULL
ENUM_VALUE_LIST OFF,ON
READ_ONLY YES
COMMAND_LINE_ARGUMENT OPTIONAL
VARIABLE_NAME INNODB_ROLLBACK_SEGMENTS
SESSION_VALUE NULL
GLOBAL_VALUE 128
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 128
VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE BIGINT UNSIGNED
VARIABLE_COMMENT Number of undo logs to use (deprecated).
NUMERIC_MIN_VALUE 1
NUMERIC_MAX_VALUE 128
NUMERIC_BLOCK_SIZE 0
ENUM_VALUE_LIST NULL
READ_ONLY NO
COMMAND_LINE_ARGUMENT OPTIONAL
VARIABLE_NAME INNODB_SAVED_PAGE_NUMBER_DEBUG
SESSION_VALUE NULL
GLOBAL_VALUE 0
......@@ -2353,8 +2339,8 @@ GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 128
VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE BIGINT UNSIGNED
VARIABLE_COMMENT Number of undo logs to use.
NUMERIC_MIN_VALUE 1
VARIABLE_COMMENT Deprecated parameter with no effect.
NUMERIC_MIN_VALUE 0
NUMERIC_MAX_VALUE 128
NUMERIC_BLOCK_SIZE 0
ENUM_VALUE_LIST NULL
......
#
# 2011-08-01 Added
#
--source include/have_innodb.inc
SET @start_global_value = @@global.innodb_rollback_segments;
SELECT @start_global_value;
#
# exists as global only
#
--echo Valid values are zero or above
SELECT @@global.innodb_rollback_segments >=0;
SELECT @@global.innodb_rollback_segments <=128;
SELECT @@global.innodb_rollback_segments;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
SELECT @@session.innodb_rollback_segments;
SHOW global variables LIKE 'innodb_rollback_segments';
SHOW session variables LIKE 'innodb_rollback_segments';
--disable_warnings
SELECT * FROM information_schema.global_variables
WHERE variable_name='innodb_rollback_segments';
SELECT * FROM information_schema.session_variables
WHERE variable_name='innodb_rollback_segments';
--enable_warnings
#
# show that it's writable
#
SET global innodb_rollback_segments=100;
SELECT @@global.innodb_rollback_segments;
--disable_warnings
SELECT * FROM information_schema.global_variables
WHERE variable_name='innodb_rollback_segments';
SELECT * FROM information_schema.session_variables
WHERE variable_name='innodb_rollback_segments';
--enable_warnings
--error ER_GLOBAL_VARIABLE
SET session innodb_rollback_segments=1;
#
# incorrect types
#
--error ER_WRONG_TYPE_FOR_VAR
SET global innodb_rollback_segments=1.1;
--error ER_WRONG_TYPE_FOR_VAR
SET global innodb_rollback_segments=1e1;
--error ER_WRONG_TYPE_FOR_VAR
SET global innodb_rollback_segments="foo";
SET global innodb_rollback_segments=-7;
SELECT @@global.innodb_rollback_segments;
--disable_warnings
SELECT * FROM information_schema.global_variables
WHERE variable_name='innodb_rollback_segments';
--enable_warnings
#
# cleanup
#
SET @@global.innodb_rollback_segments = @start_global_value;
SELECT @@global.innodb_rollback_segments;
################## mysql-test/t/innodb_undo_logs_basic.test ############
# #
# Variable Name: innodb_undo_logs #
# Scope: Global #
# Access Type: Static #
# Data Type: numeric #
# #
# #
# Creation Date: 2011-07-05 #
# Author : Sunny Bains #
# #
# #
# Description: Read-only config global variable innodb_undo_logs #
# * Value check #
# * Scope check #
# #
###############################################################################
#
# 2011-08-01 Added
#
--source include/have_innodb.inc
####################################################################
# Display default value #
####################################################################
SELECT @@GLOBAL.innodb_undo_logs;
--echo 128 Expected
####################################################################
# Check if value can be set #
####################################################################
SET @@GLOBAL.innodb_undo_logs=128;
SELECT COUNT(@@GLOBAL.innodb_undo_logs);
--echo 1 Expected
################################################################################
# Check if the value in GLOBAL table matches value in variable #
################################################################################
#
# exists as global only
#
SELECT @@global.innodb_undo_logs;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
SELECT @@session.innodb_undo_logs;
SHOW global variables LIKE 'innodb_undo_logs';
SHOW session variables LIKE 'innodb_undo_logs';
--disable_warnings
SELECT VARIABLE_VALUE
FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
WHERE VARIABLE_NAME='innodb_undo_logs';
SELECT * FROM information_schema.global_variables
WHERE variable_name='innodb_undo_logs';
SELECT * FROM information_schema.session_variables
WHERE variable_name='innodb_undo_logs';
--enable_warnings
--echo 128 Expected
################################################################################
# Check if accessing variable with and without GLOBAL point to same variable #
################################################################################
SELECT @@innodb_undo_logs = @@GLOBAL.innodb_undo_logs;
--echo 1 Expected
################################################################################
# Check if innodb_undo_logs can be accessed with and without @@ sign #
################################################################################
SELECT COUNT(@@innodb_undo_logs);
--echo 1 Expected
--Error ER_INCORRECT_GLOBAL_LOCAL_VAR
SELECT COUNT(@@local.innodb_undo_logs);
--echo Expected error 'Variable is a GLOBAL variable'
--Error ER_INCORRECT_GLOBAL_LOCAL_VAR
SELECT COUNT(@@SESSION.innodb_undo_logs);
--echo Expected error 'Variable is a GLOBAL variable'
--Error ER_BAD_FIELD_ERROR
SELECT innodb_undo_logs = @@SESSION.innodb_undo_logs;
# Begin Bug 13604034
# SET GLOBAL INNODB_UNDO_LOGS=0 SUCCEEDS BUT LEADS TO AN ASSERT
# MAX_UNDO_LOGS > 0
--echo Begin bug 13604034
select @@innodb_undo_logs;
--echo 128 Expected
set global innodb_undo_logs = 129;
select @@innodb_undo_logs;
--echo 128 Expected
set global innodb_undo_logs = 0;
select @@innodb_undo_logs;
--echo 1 Expected
set global innodb_undo_logs = -1;
select @@innodb_undo_logs;
--echo 1 Expected
set global innodb_undo_logs = 50;
select @@innodb_undo_logs;
--echo 50 Expected
set global innodb_undo_logs = default;
select @@innodb_undo_logs;
--echo 128 Expected
--echo End bug 13604034
# End Bug 13604034
SET global innodb_undo_logs=100;
SELECT @@global.innodb_undo_logs;
--error ER_GLOBAL_VARIABLE
SET session innodb_undo_logs=1;
#
# incorrect types
#
--error ER_WRONG_TYPE_FOR_VAR
SET global innodb_undo_logs=1.1;
--error ER_WRONG_TYPE_FOR_VAR
SET global innodb_undo_logs=1e1;
--error ER_WRONG_TYPE_FOR_VAR
SET global innodb_undo_logs="foo";
SET global innodb_undo_logs=-7;
SELECT @@global.innodb_undo_logs;
--disable_warnings
SELECT * FROM information_schema.global_variables
WHERE variable_name='innodb_undo_logs';
--enable_warnings
......@@ -1054,8 +1054,7 @@ static SHOW_VAR innodb_status_variables[]= {
(char*) &export_vars.innodb_num_open_files, SHOW_LONG},
{"truncated_status_writes",
(char*) &export_vars.innodb_truncated_status_writes, SHOW_LONG},
{"available_undo_logs",
(char*) &export_vars.innodb_available_undo_logs, SHOW_LONG},
{"available_undo_logs", &srv_available_undo_logs, SHOW_ULONG},
{"undo_truncations",
(char*) &export_vars.innodb_undo_truncations, SHOW_LONG},
......@@ -3656,6 +3655,11 @@ static my_bool innodb_log_checksums;
/** Deprecation message for innodb_log_checksums */
static const char* innodb_log_checksums_deprecated
= "The parameter innodb_log_checksums is deprecated and has no effect.";
/** Deprecated parameter with no effect */
static ulong innodb_undo_logs;
/** Deprecation message for innodb_undo_logs */
static const char* innodb_undo_logs_deprecated
= "The parameter innodb_undo_logs is deprecated and has no effect.";
/** Initialize, validate and normalize the InnoDB startup parameters.
@return failure code
......@@ -3971,11 +3975,16 @@ static int innodb_init_params()
srv_buf_pool_size = ulint(innobase_buffer_pool_size);
if (!innodb_log_checksums) {
if (UNIV_UNLIKELY(!innodb_log_checksums)) {
sql_print_warning(innodb_log_checksums_deprecated);
innodb_log_checksums = TRUE;
}
if (UNIV_UNLIKELY(innodb_undo_logs != TRX_SYS_N_RSEGS)) {
sql_print_warning(innodb_undo_logs_deprecated);
innodb_undo_logs = TRX_SYS_N_RSEGS;
}
row_rollback_on_timeout = (ibool) innobase_rollback_on_timeout;
if (innobase_open_files < 10) {
......@@ -12849,8 +12858,7 @@ inline int ha_innobase::delete_table(const char* name, enum_sql_command sqlcom)
extension, in contrast to ::create */
normalize_table_name(norm_name, name);
if (srv_read_only_mode
|| srv_force_recovery >= SRV_FORCE_NO_UNDO_LOG_SCAN) {
if (high_level_read_only) {
DBUG_RETURN(HA_ERR_TABLE_READONLY);
}
......@@ -18464,6 +18472,16 @@ innodb_log_checksums_warn(THD* thd, st_mysql_sys_var*, void*, const void*)
innodb_log_checksums_deprecated);
}
/** Issue a deprecation warning for SET GLOBAL innodb_undo_logs.
@param[in,out] thd client connection */
static void
innodb_undo_logs_warn(THD* thd, st_mysql_sys_var*, void*, const void*)
{
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
HA_ERR_UNSUPPORTED,
innodb_undo_logs_deprecated);
}
static SHOW_VAR innodb_status_variables_export[]= {
{"Innodb", (char*) &show_innodb_vars, SHOW_FUNC},
{NullS, NullS, SHOW_LONG}
......@@ -18658,10 +18676,13 @@ static MYSQL_SYSVAR_ENUM(checksum_algorithm, srv_checksum_algorithm,
NULL, NULL, SRV_CHECKSUM_ALGORITHM_FULL_CRC32,
&innodb_checksum_algorithm_typelib);
/** Description of deprecated and ignored parameters */
static const char* innodb_deprecated_ignored
= "Deprecated parameter with no effect.";
static MYSQL_SYSVAR_BOOL(log_checksums, innodb_log_checksums,
PLUGIN_VAR_RQCMDARG,
"Deprecated parameter with no effect.",
NULL, innodb_log_checksums_warn, TRUE);
innodb_deprecated_ignored, NULL, innodb_log_checksums_warn, TRUE);
static MYSQL_SYSVAR_STR(data_home_dir, innobase_data_home_dir,
PLUGIN_VAR_READONLY,
......@@ -18804,10 +18825,10 @@ static MYSQL_SYSVAR_ENUM(flush_method, innodb_flush_method,
static MYSQL_SYSVAR_STR(file_format, innodb_file_format,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"Deprecated parameter with no effect.", NULL, NULL, NULL);
innodb_deprecated_ignored, NULL, NULL, NULL);
static MYSQL_SYSVAR_STR(large_prefix, innodb_large_prefix,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"Deprecated parameter with no effect.", NULL, NULL, NULL);
innodb_deprecated_ignored, NULL, NULL, NULL);
static MYSQL_SYSVAR_BOOL(force_load_corrupted, srv_load_corrupted,
PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
......@@ -19377,13 +19398,10 @@ static MYSQL_SYSVAR_ULONG(undo_tablespaces, srv_undo_tablespaces,
0L, /* Minimum value */
TRX_SYS_MAX_UNDO_SPACES, 0); /* Maximum value */
static MYSQL_SYSVAR_ULONG(undo_logs, srv_undo_logs,
static MYSQL_SYSVAR_ULONG(undo_logs, innodb_undo_logs,
PLUGIN_VAR_OPCMDARG,
"Number of undo logs to use.",
NULL, NULL,
TRX_SYS_N_RSEGS, /* Default setting */
1, /* Minimum value */
TRX_SYS_N_RSEGS, 0); /* Maximum value */
innodb_deprecated_ignored, NULL, innodb_undo_logs_warn,
TRX_SYS_N_RSEGS, 0, TRX_SYS_N_RSEGS, 0);
static MYSQL_SYSVAR_ULONGLONG(max_undo_log_size, srv_max_undo_log_size,
PLUGIN_VAR_OPCMDARG,
......@@ -19404,15 +19422,6 @@ static MYSQL_SYSVAR_BOOL(undo_log_truncate, srv_undo_log_truncate,
"Enable or Disable Truncate of UNDO tablespace.",
NULL, NULL, FALSE);
/* Alias for innodb_undo_logs, this config variable is deprecated. */
static MYSQL_SYSVAR_ULONG(rollback_segments, srv_undo_logs,
PLUGIN_VAR_OPCMDARG,
"Number of undo logs to use (deprecated).",
NULL, NULL,
TRX_SYS_N_RSEGS, /* Default setting */
1, /* Minimum value */
TRX_SYS_N_RSEGS, 0); /* Maximum value */
static MYSQL_SYSVAR_LONG(autoinc_lock_mode, innobase_autoinc_lock_mode,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"The AUTOINC lock modes supported by InnoDB:"
......@@ -19955,7 +19964,6 @@ static struct st_mysql_sys_var* innobase_system_variables[]= {
MYSQL_SYSVAR(max_undo_log_size),
MYSQL_SYSVAR(purge_rseg_truncate_frequency),
MYSQL_SYSVAR(undo_log_truncate),
MYSQL_SYSVAR(rollback_segments),
MYSQL_SYSVAR(undo_directory),
MYSQL_SYSVAR(undo_tablespaces),
MYSQL_SYSVAR(sync_array_size),
......
......@@ -305,9 +305,6 @@ srv_is_undo_tablespace(ulint space_id)
+ srv_undo_tablespaces_open);
}
/** The number of undo segments to use */
extern ulong srv_undo_logs;
/** Maximum size of undo tablespace. */
extern unsigned long long srv_max_undo_log_size;
......@@ -966,8 +963,6 @@ struct export_var_t{
ulint innodb_system_rows_deleted; /*!< srv_n_system_rows_deleted*/
ulint innodb_num_open_files; /*!< fil_system_t::n_open */
ulint innodb_truncated_status_writes; /*!< srv_truncated_status_writes */
ulint innodb_available_undo_logs; /*!< srv_available_undo_logs
*/
/** Number of undo tablespace truncation operations */
ulong innodb_undo_truncations;
ulint innodb_defragment_compression_failures; /*!< Number of
......
......@@ -446,8 +446,6 @@ typedef ib_uint64_t lsn_t;
/** The 'undefined' value for a ulint */
#define ULINT_UNDEFINED ((ulint)(-1))
#define ULONG_UNDEFINED ((ulong)(-1))
/** The 'undefined' value for a ib_uint64_t */
#define UINT64_UNDEFINED ((ib_uint64_t)(-1))
......
......@@ -55,8 +55,6 @@ Created 9/20/1997 Heikki Tuuri
#include "buf0rea.h"
#include "srv0srv.h"
#include "srv0start.h"
#include "trx0roll.h"
#include "row0merge.h"
/** Log records are stored in the hash table in chunks at most of this size;
this must be less than srv_page_size as it is stored in the buffer pool */
......@@ -117,7 +115,6 @@ the recovery failed and the database may be corrupt. */
static lsn_t recv_max_page_lsn;
#ifdef UNIV_PFS_THREAD
mysql_pfs_key_t trx_rollback_clean_thread_key;
mysql_pfs_key_t recv_writer_thread_key;
#endif /* UNIV_PFS_THREAD */
......@@ -3826,43 +3823,8 @@ recv_recovery_from_checkpoint_finish(void)
/* Free up the flush_rbt. */
buf_flush_free_flush_rbt();
}
/********************************************************//**
Initiates the rollback of active transactions. */
void
recv_recovery_rollback_active(void)
/*===============================*/
{
ut_ad(!recv_writer_thread_active);
/* Switch latching order checks on in sync0debug.cc, if
--innodb-sync-debug=true (default) */
/* Enable innodb_sync_debug checks */
ut_d(sync_check_enable());
/* We can't start any (DDL) transactions if UNDO logging
has been disabled, additionally disable ROLLBACK of recovered
user transactions. */
if (srv_force_recovery < SRV_FORCE_NO_TRX_UNDO
&& !srv_read_only_mode) {
/* Drop partially created indexes. */
row_merge_drop_temp_indexes();
/* Drop garbage tables. */
row_mysql_drop_garbage_tables();
/* Drop any auxiliary tables that were not dropped when the
parent table was dropped. This can happen if the parent table
was dropped but the server crashed before the auxiliary tables
were dropped. */
fts_drop_orphaned_tables();
/* Rollback the uncommitted transactions which have no user
session */
trx_rollback_is_active = true;
os_thread_create(trx_rollback_all_recovered, 0, 0);
}
}
/** Find a doublewrite copy of a page.
......
......@@ -117,9 +117,6 @@ segment). It is quite possible that some of the tablespaces doesn't host
any of the rollback-segment based on configuration used. */
ulint srv_undo_tablespaces_active;
/* The number of rollback segments to use */
ulong srv_undo_logs;
/** Rate at which UNDO records should be purged. */
ulong srv_purge_rseg_truncate_frequency;
......@@ -1568,7 +1565,6 @@ srv_export_innodb_status(void)
export_vars.innodb_truncated_status_writes =
srv_truncated_status_writes;
export_vars.innodb_available_undo_logs = srv_available_undo_logs;
export_vars.innodb_page_compression_saved = srv_stats.page_compression_saved;
export_vars.innodb_index_pages_written = srv_stats.index_pages_written;
export_vars.innodb_non_index_pages_written = srv_stats.non_index_pages_written;
......
......@@ -1307,7 +1307,6 @@ dberr_t srv_start(bool create_new_db)
|| srv_operation == SRV_OPERATION_RESTORE
|| srv_operation == SRV_OPERATION_RESTORE_EXPORT);
if (srv_force_recovery == SRV_FORCE_NO_LOG_REDO) {
srv_read_only_mode = true;
}
......@@ -2099,10 +2098,39 @@ dberr_t srv_start(bool create_new_db)
return(srv_init_abort(err));
}
}
}
ut_ad(err == DB_SUCCESS);
ut_a(sum_of_new_sizes != ULINT_UNDEFINED);
/* Create the doublewrite buffer to a new tablespace */
if (!srv_read_only_mode && srv_force_recovery < SRV_FORCE_NO_TRX_UNDO
&& !buf_dblwr_create()) {
return(srv_init_abort(DB_ERROR));
}
/* Here the double write buffer has already been created and so
any new rollback segments will be allocated after the double
write buffer. The default segment should already exist.
We create the new segments only if it's a new database or
the database was shutdown cleanly. */
/* Note: When creating the extra rollback segments during an upgrade
we violate the latching order, even if the change buffer is empty.
We make an exception in sync0sync.cc and check srv_is_being_started
for that violation. It cannot create a deadlock because we are still
running in single threaded mode essentially. Only the IO threads
should be running at this stage. */
if (!trx_sys_create_rsegs()) {
return(srv_init_abort(DB_ERROR));
}
if (!create_new_db) {
/* Validate a few system page types that were left
uninitialized by older versions of MySQL. */
uninitialized before MySQL or MariaDB 5.5. */
if (!high_level_read_only) {
ut_ad(srv_force_recovery < SRV_FORCE_NO_IBUF_MERGE);
buf_block_t* block;
mtr.start();
/* Bitmap page types will be reset in
......@@ -2130,16 +2158,20 @@ dberr_t srv_start(bool create_new_db)
0, RW_X_LATCH, &mtr);
fil_block_check_type(*block, FIL_PAGE_TYPE_SYS, &mtr);
mtr.commit();
}
/* Roll back any recovered data dictionary transactions, so
that the data dictionary tables will be free of any locks.
The data dictionary latch should guarantee that there is at
most one data dictionary transaction active at a time. */
/* Roll back any recovered data dictionary
transactions, so that the data dictionary
tables will be free of any locks. The data
dictionary latch should guarantee that there
is at most one data dictionary transaction
active at a time. */
if (srv_force_recovery < SRV_FORCE_NO_TRX_UNDO) {
trx_rollback_recovered(false);
}
}
/* FIXME: Skip the following if srv_read_only_mode,
while avoiding "Allocated tablespace ID" warnings. */
if (srv_force_recovery < SRV_FORCE_NO_IBUF_MERGE) {
/* Open or Create SYS_TABLESPACES and SYS_DATAFILES
so that tablespace names and other metadata can be
......@@ -2166,41 +2198,24 @@ dberr_t srv_start(bool create_new_db)
dict_check_tablespaces_and_store_max_id();
}
if (err != DB_SUCCESS) {
return(srv_init_abort(err));
}
recv_recovery_rollback_active();
srv_startup_is_before_trx_rollback_phase = FALSE;
}
if (srv_force_recovery < SRV_FORCE_NO_TRX_UNDO
&& !srv_read_only_mode) {
/* Drop partially created indexes. */
row_merge_drop_temp_indexes();
/* Drop garbage tables. */
row_mysql_drop_garbage_tables();
ut_ad(err == DB_SUCCESS);
ut_a(sum_of_new_sizes != ULINT_UNDEFINED);
/* Drop any auxiliary tables that were not
dropped when the parent table was
dropped. This can happen if the parent table
was dropped but the server crashed before the
auxiliary tables were dropped. */
fts_drop_orphaned_tables();
/* Create the doublewrite buffer to a new tablespace */
if (!srv_read_only_mode && srv_force_recovery < SRV_FORCE_NO_TRX_UNDO
&& !buf_dblwr_create()) {
return(srv_init_abort(DB_ERROR));
/* Rollback incomplete non-DDL transactions */
trx_rollback_is_active = true;
os_thread_create(trx_rollback_all_recovered, 0, 0);
}
/* Here the double write buffer has already been created and so
any new rollback segments will be allocated after the double
write buffer. The default segment should already exist.
We create the new segments only if it's a new database or
the database was shutdown cleanly. */
/* Note: When creating the extra rollback segments during an upgrade
we violate the latching order, even if the change buffer is empty.
We make an exception in sync0sync.cc and check srv_is_being_started
for that violation. It cannot create a deadlock because we are still
running in single threaded mode essentially. Only the IO threads
should be running at this stage. */
ut_a(srv_undo_logs > 0);
ut_a(srv_undo_logs <= TRX_SYS_N_RSEGS);
if (!trx_sys_create_rsegs()) {
return(srv_init_abort(DB_ERROR));
}
srv_startup_is_before_trx_rollback_phase = false;
......
......@@ -568,7 +568,7 @@ static void trx_purge_truncate_history()
return;
}
while (srv_undo_log_truncate && srv_undo_logs >= 3) {
while (srv_undo_log_truncate) {
if (!purge_sys.truncate.current) {
const ulint threshold = ulint(srv_max_undo_log_size
>> srv_page_size_shift);
......
......@@ -44,6 +44,10 @@ Created 3/26/1996 Heikki Tuuri
#include "trx0trx.h"
#include "trx0undo.h"
#ifdef UNIV_PFS_THREAD
mysql_pfs_key_t trx_rollback_clean_thread_key;
#endif
/** true if trx_rollback_all_recovered() thread is active */
bool trx_rollback_is_active;
......@@ -833,7 +837,6 @@ void trx_rollback_recovered(bool all)
}
}
/*******************************************************************//**
Rollback or clean up any incomplete transactions which were
encountered in crash recovery. If the transaction already was
......
......@@ -238,16 +238,11 @@ trx_sys_create_rsegs()
{
/* srv_available_undo_logs reflects the number of persistent
rollback segments that have been initialized in the
transaction system header page.
srv_undo_logs determines how many of the
srv_available_undo_logs rollback segments may be used for
logging new transactions. */
transaction system header page. */
ut_ad(srv_undo_tablespaces <= TRX_SYS_MAX_UNDO_SPACES);
ut_ad(srv_undo_logs <= TRX_SYS_N_RSEGS);
if (srv_read_only_mode) {
srv_undo_logs = srv_available_undo_logs = ULONG_UNDEFINED;
if (high_level_read_only) {
srv_available_undo_logs = 0;
return(true);
}
......@@ -262,14 +257,7 @@ trx_sys_create_rsegs()
in the system tablespace. */
ut_a(srv_available_undo_logs > 0);
if (srv_force_recovery) {
/* Do not create additional rollback segments if
innodb_force_recovery has been set. */
if (srv_undo_logs > srv_available_undo_logs) {
srv_undo_logs = srv_available_undo_logs;
}
} else {
for (ulint i = 0; srv_available_undo_logs < srv_undo_logs;
for (ulint i = 0; srv_available_undo_logs < TRX_SYS_N_RSEGS;
i++, srv_available_undo_logs++) {
/* Tablespace 0 is the system tablespace.
Dedicated undo log tablespaces start from 1. */
......@@ -293,12 +281,11 @@ trx_sys_create_rsegs()
ut_ad(srv_undo_tablespaces_active == space);
}
}
}
ut_ad(srv_undo_logs <= srv_available_undo_logs);
ut_ad(srv_available_undo_logs == TRX_SYS_N_RSEGS);
ib::info info;
info << srv_undo_logs << " out of " << srv_available_undo_logs;
info << srv_available_undo_logs;
if (srv_undo_tablespaces_active) {
info << " rollback segments in " << srv_undo_tablespaces_active
<< " undo tablespaces are active.";
......
......@@ -776,11 +776,13 @@ evenly distributed between 0 and innodb_undo_logs-1
@retval NULL if innodb_read_only */
static trx_rseg_t* trx_assign_rseg_low()
{
if (srv_read_only_mode) {
ut_ad(srv_undo_logs == ULONG_UNDEFINED);
if (high_level_read_only) {
ut_ad(!srv_available_undo_logs);
return(NULL);
}
ut_ad(srv_available_undo_logs == TRX_SYS_N_RSEGS);
/* The first slot is always assigned to the system tablespace. */
ut_ad(trx_sys.rseg_array[0]->space == fil_system.sys_space);
......@@ -793,7 +795,8 @@ static trx_rseg_t* trx_assign_rseg_low()
that start modifications concurrently will write their undo
log to the same rollback segment. */
static ulong rseg_slot;
ulint slot = rseg_slot++ % srv_undo_logs;
ulint slot = rseg_slot++ % TRX_SYS_N_RSEGS;
ut_d(if (trx_rseg_n_slots_debug) slot = 0);
trx_rseg_t* rseg;
#ifdef UNIV_DEBUG
......@@ -816,7 +819,8 @@ static trx_rseg_t* trx_assign_rseg_low()
look_for_rollover = true;
#endif /* UNIV_DEBUG */
slot = (slot + 1) % srv_undo_logs;
ut_d(if (!trx_rseg_n_slots_debug))
slot = (slot + 1) % TRX_SYS_N_RSEGS;
if (rseg == NULL) {
continue;
......
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