-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adapt the innodb_undo tests from MySQL 5.7
Simplify the tests that are present in MySQL 5.7. Make the table smaller while generating enough undo log. Do not unnecessarily drop tables. trx_purge_initiate_truncate(): Remove two crash injection points (before and after normal redo log checkpoint), because they are not adding any value. Clarify some messages. trx_sys_create_rsegs(): Display the number of active undo tablespaces. srv_undo_tablespaces_init(): When initializing the data files, do not leave srv_undo_tablespaces_active at 0. Do not display that number; let trx_sys_create_rsegs() display it once the final number is known. innodb_params_adjust(): Adjust parameters after startup. innobase_init(): Do not allow innodb_max_undo_size to be less than SRV_UNDO_TABLESPACE_SIZE_IN_PAGES. This avoids unnecessary repeated truncation of undo tablespaces when using innodb_page_size=32k or innodb_page_size=64k.
- Loading branch information
Showing
16 changed files
with
363 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
if (`SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE LOWER(variable_name) = 'innodb_page_size' AND variable_value <= 16384`) | ||
{ | ||
--skip Test requires InnoDB with page size not greater than 16k. | ||
} |
4 changes: 4 additions & 0 deletions
4
mysql-test/suite/innodb_undo/include/have_undo_tablespaces.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
if (`select count(*) = 0 from information_schema.global_variables where variable_name like 'innodb_undo_tablespaces' and variable_value >= 2`) | ||
{ | ||
--skip Test requires InnoDB with at-least 2 undo tablespaces. | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
begin; | ||
update t1 set c = 'MariaDB'; | ||
update t1 set c = 'InnoDB'; | ||
eval set global debug_dbug = '+d,$SEARCH_PATTERN'; | ||
commit; | ||
--source include/shutdown_mysqld.inc | ||
--source include/search_pattern_in_file.inc | ||
--source include/start_mysqld.inc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
SET GLOBAL innodb_fast_shutdown=0; | ||
create table t1(keyc int primary key, c1 char(100)) engine = innodb; | ||
begin; | ||
update t1 set c1 = 'mysql'; | ||
update t1 set c1 = 'oracle'; | ||
delete from t1; | ||
commit; | ||
drop table t1; | ||
SET GLOBAL innodb_fast_shutdown=0; | ||
SET GLOBAL innodb_undo_log_truncate=1; | ||
SET GLOBAL innodb_purge_rseg_truncate_frequency=1; |
51 changes: 51 additions & 0 deletions
51
mysql-test/suite/innodb_undo/r/truncate_multi_client.result
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
SET GLOBAL innodb_fast_shutdown=0; | ||
create table t1(keyc int primary key, c char(100)) engine = innodb; | ||
create table t2(keyc int primary key, c char(100)) engine = innodb; | ||
CREATE PROCEDURE populate_t1() | ||
BEGIN | ||
DECLARE i INT DEFAULT 1; | ||
while (i <= 20000) DO | ||
insert into t1 values (i, 'a'); | ||
SET i = i + 1; | ||
END WHILE; | ||
END | | ||
CREATE PROCEDURE populate_t2() | ||
BEGIN | ||
DECLARE i INT DEFAULT 1; | ||
while (i <= 20000) DO | ||
insert into t2 values (i, 'a'); | ||
SET i = i + 1; | ||
END WHILE; | ||
END | | ||
connect con1,localhost,root,,; | ||
begin; | ||
call populate_t1(); | ||
connect con2,localhost,root,,; | ||
begin; | ||
call populate_t2(); | ||
connection con1; | ||
update t1 set c = 'mysql'; | ||
connection con2; | ||
update t2 set c = 'mysql'; | ||
connection con1; | ||
update t1 set c = 'oracle'; | ||
connection con2; | ||
update t2 set c = 'oracle'; | ||
connection con1; | ||
delete from t1; | ||
connection con2; | ||
delete from t2; | ||
connection con1; | ||
commit; | ||
disconnect con1; | ||
connection con2; | ||
commit; | ||
disconnect con2; | ||
connection default; | ||
drop table t1, t2; | ||
drop PROCEDURE populate_t1; | ||
drop PROCEDURE populate_t2; | ||
SET GLOBAL innodb_fast_shutdown=0; | ||
SET GLOBAL innodb_undo_log_truncate=1; | ||
SET GLOBAL innodb_purge_rseg_truncate_frequency=1; | ||
FOUND 1 /Truncating UNDO tablespace 1/ in mysqld.1.err |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
create table t1(keyc int primary key, c char(100)) engine = innodb; | ||
begin; | ||
commit; | ||
begin; | ||
update t1 set c = 'MariaDB'; | ||
update t1 set c = 'InnoDB'; | ||
set global debug_dbug = '+d,ib_undo_trunc_before_truncate'; | ||
commit; | ||
FOUND 1 /ib_undo_trunc_before_truncate/ in mysqld.1.err | ||
begin; | ||
update t1 set c = 'MariaDB'; | ||
update t1 set c = 'InnoDB'; | ||
set global debug_dbug = '+d,ib_undo_trunc_before_ddl_log_end'; | ||
commit; | ||
FOUND 1 /ib_undo_trunc_before_ddl_log_end/ in mysqld.1.err |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# | ||
# WL#6965: Truncate UNDO logs. | ||
# | ||
|
||
--source include/have_innodb.inc | ||
--source include/have_innodb_max_16k.inc | ||
--source include/have_undo_tablespaces.inc | ||
|
||
# The test is restarting the server to force undo truncation. | ||
--source include/not_embedded.inc | ||
|
||
SET GLOBAL innodb_fast_shutdown=0; | ||
--let $restart_parameters=--innodb_undo_tablespaces=2 --innodb_undo_logs=4 | ||
--source include/restart_mysqld.inc | ||
|
||
let MYSQLD_DATADIR = `select @@datadir`; | ||
|
||
#----------------------------------------------------------------------------- | ||
# | ||
# 1. Perform enough DML action so that undo tablespace size grows beyond | ||
# set threshold and then wait and see if it is being truncated. | ||
# | ||
create table t1(keyc int primary key, c1 char(100)) engine = innodb; | ||
begin; | ||
--disable_query_log | ||
let $i=30000; | ||
while ($i) { | ||
eval insert into t1 values(30000-$i, ''); | ||
dec $i; | ||
} | ||
--enable_query_log | ||
update t1 set c1 = 'mysql'; | ||
update t1 set c1 = 'oracle'; | ||
delete from t1; | ||
commit; | ||
drop table t1; | ||
|
||
let CHECKFILE = $MYSQL_TMP_DIR/check.txt; | ||
perl; | ||
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size1) | ||
= stat("$ENV{MYSQLD_DATADIR}/undo001"); | ||
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size2) | ||
= stat("$ENV{MYSQLD_DATADIR}/undo002"); | ||
open(OUT, ">$ENV{CHECKFILE}") || die; | ||
print OUT "let \$size1='$size1,$size2';\n"; | ||
close(OUT); | ||
EOF | ||
SET GLOBAL innodb_fast_shutdown=0; | ||
SET GLOBAL innodb_undo_log_truncate=1; | ||
SET GLOBAL innodb_purge_rseg_truncate_frequency=1; | ||
--source include/shutdown_mysqld.inc | ||
--source $CHECKFILE | ||
perl; | ||
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size1) | ||
= stat("$ENV{MYSQLD_DATADIR}/undo001"); | ||
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size2) | ||
= stat("$ENV{MYSQLD_DATADIR}/undo002"); | ||
open(OUT, ">$ENV{CHECKFILE}") || die; | ||
print OUT "let \$size2='$size1,$size2';\n"; | ||
close(OUT); | ||
EOF | ||
|
||
--source $CHECKFILE | ||
--remove_file $CHECKFILE | ||
|
||
if ($size1 == $size2) | ||
{ | ||
echo Truncation did not happen: $size1 == $size2; | ||
} | ||
|
||
--let $restart_parameters= | ||
--source include/start_mysqld.inc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# | ||
# WL#6965: Truncate UNDO logs. | ||
# | ||
|
||
--source include/have_innodb.inc | ||
# This test is restarting the server. | ||
--source include/not_embedded.inc | ||
# With larger innodb_page_size, the undo log tablespaces do not grow enough. | ||
--source include/have_innodb_max_16k.inc | ||
--source include/have_undo_tablespaces.inc | ||
|
||
SET GLOBAL innodb_fast_shutdown=0; | ||
--let $restart_parameters=--innodb_undo_tablespaces=2 --innodb_undo_logs=4 | ||
--source include/restart_mysqld.inc | ||
|
||
#----------------------------------------------------------------------------- | ||
# | ||
# Perform DML action using multiple clients and multiple undo tablespace. | ||
# | ||
# | ||
create table t1(keyc int primary key, c char(100)) engine = innodb; | ||
create table t2(keyc int primary key, c char(100)) engine = innodb; | ||
# | ||
delimiter |; | ||
CREATE PROCEDURE populate_t1() | ||
BEGIN | ||
DECLARE i INT DEFAULT 1; | ||
while (i <= 20000) DO | ||
insert into t1 values (i, 'a'); | ||
SET i = i + 1; | ||
END WHILE; | ||
END | | ||
delimiter ;| | ||
# | ||
delimiter |; | ||
CREATE PROCEDURE populate_t2() | ||
BEGIN | ||
DECLARE i INT DEFAULT 1; | ||
while (i <= 20000) DO | ||
insert into t2 values (i, 'a'); | ||
SET i = i + 1; | ||
END WHILE; | ||
END | | ||
delimiter ;| | ||
# | ||
# | ||
connect (con1,localhost,root,,); | ||
begin; | ||
send call populate_t1(); | ||
|
||
connect (con2,localhost,root,,); | ||
begin; | ||
send call populate_t2(); | ||
|
||
connection con1; reap; send update t1 set c = 'mysql'; | ||
connection con2; reap; send update t2 set c = 'mysql'; | ||
connection con1; reap; send update t1 set c = 'oracle'; | ||
connection con2; reap; send update t2 set c = 'oracle'; | ||
connection con1; reap; send delete from t1; | ||
connection con2; reap; send delete from t2; | ||
connection con1; reap; commit; disconnect con1; | ||
connection con2; reap; commit; disconnect con2; | ||
|
||
connection default; | ||
drop table t1, t2; | ||
drop PROCEDURE populate_t1; | ||
drop PROCEDURE populate_t2; | ||
|
||
SET GLOBAL innodb_fast_shutdown=0; | ||
SET GLOBAL innodb_undo_log_truncate=1; | ||
SET GLOBAL innodb_purge_rseg_truncate_frequency=1; | ||
|
||
--source include/restart_mysqld.inc | ||
|
||
let SEARCH_FILE = $MYSQLTEST_VARDIR/log/mysqld.1.err; | ||
let SEARCH_PATTERN = Truncating UNDO tablespace 1; | ||
--source include/search_pattern_in_file.inc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# | ||
# WL#6965: Truncate UNDO logs. | ||
# | ||
|
||
--source include/have_innodb.inc | ||
--source include/have_debug.inc | ||
# With larger innodb_page_size, the undo log tablespaces do not grow enough. | ||
--source include/have_innodb_max_16k.inc | ||
--source include/have_undo_tablespaces.inc | ||
|
||
# Valgrind would complain about memory leaks when we crash on purpose. | ||
--source include/not_valgrind.inc | ||
# Embedded server does not support crashing | ||
--source include/not_embedded.inc | ||
# Avoid CrashReporter popup on Mac | ||
--source include/not_crashrep.inc | ||
|
||
--disable_query_log | ||
# FIXME: The doublewrite buffer should not issue these warnings. | ||
# FIXME: Maybe buf_dblwr_process() should empty the buffer at the end? | ||
call mtr.add_suppression("InnoDB: A copy of page.*in the doublewrite buffer slot.*is not within space bounds"); | ||
FLUSH TABLES; | ||
--enable_query_log | ||
|
||
--let $restart_parameters=--innodb-undo-logs=4 --innodb-undo-tablespaces=2 --innodb-undo-log-truncate=1 --innodb-max-undo-log-size=10485760 --innodb-purge-rseg-truncate-frequency=1 --innodb-fast-shutdown=0 | ||
--source include/restart_mysqld.inc | ||
|
||
let SEARCH_FILE = $MYSQLTEST_VARDIR/log/mysqld.1.err; | ||
|
||
create table t1(keyc int primary key, c char(100)) engine = innodb; | ||
begin; | ||
--disable_query_log | ||
let $i=30000; | ||
while ($i) { | ||
eval insert into t1 values(30000-$i, ''); | ||
dec $i; | ||
} | ||
--enable_query_log | ||
commit; | ||
|
||
let SEARCH_PATTERN = ib_undo_trunc_before_truncate; | ||
--source include/truncate_recover.inc | ||
|
||
let SEARCH_PATTERN = ib_undo_trunc_before_ddl_log_end; | ||
--source include/truncate_recover.inc | ||
|
||
let SEARCH_PATTERN = ib_undo_trunc_trunc_done; | ||
let $restart_parameters= | ||
--source include/truncate_recover.inc | ||
drop table t1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.