203 lines
5.6 KiB
Plaintext
203 lines
5.6 KiB
Plaintext
--echo #
|
|
--echo # WL#6965: Truncate UNDO logs.
|
|
--echo #
|
|
|
|
# This test uses debug settings like innodb_purge_stop_now.
|
|
--source include/have_debug.inc
|
|
|
|
# Valgrind would complain about memory leaks when we crash on purpose.
|
|
--source include/not_valgrind.inc
|
|
|
|
# Avoid CrashReporter popup on Mac
|
|
--source include/not_crashrep.inc
|
|
|
|
--source include/big_test.inc
|
|
--source include/have_innodb_default_undo_tablespaces.inc
|
|
|
|
|
|
SHOW VARIABLES LIKE 'innodb_rollback_segments';
|
|
SELECT NAME, SPACE_TYPE, STATE FROM INFORMATION_SCHEMA.INNODB_TABLESPACES
|
|
WHERE SPACE_TYPE = 'Undo' ORDER BY NAME;
|
|
|
|
################################################################################
|
|
# Test-case will test following scenarios.
|
|
#
|
|
# 1. Perform enough DML action so that undo tablespace sizes grow beyond
|
|
# set threshold and then wait and see if it is being truncated.
|
|
#
|
|
################################################################################
|
|
|
|
#-----------------------------------------------------------------------------
|
|
#
|
|
# create test-bed
|
|
#
|
|
let MYSQLD_DATADIR = `select @@datadir`;
|
|
|
|
#-----------------------------------------------------------------------------
|
|
#
|
|
# 1. Perform enough DML action so that undo tablespace sizes grow beyond
|
|
# set threshold and then wait and see if it is being truncated.
|
|
#
|
|
|
|
# Storing the initial sizes of the tablespaces before DML action
|
|
|
|
SET GLOBAL innodb_purge_stop_now=ON;
|
|
|
|
let CHECKFILE = $MYSQLTEST_VARDIR/tmp/check.txt;
|
|
|
|
perl;
|
|
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$init1)
|
|
= stat("$ENV{MYSQLD_DATADIR}/undo_001");
|
|
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$init2)
|
|
= stat("$ENV{MYSQLD_DATADIR}/undo_002");
|
|
open(OUT, ">$ENV{CHECKFILE}") || die;
|
|
print OUT "let \$init1= $init1;\n";
|
|
print OUT "let \$init2= $init2;\n";
|
|
close(OUT);
|
|
EOF
|
|
--source $CHECKFILE
|
|
|
|
# Start of the first transaction that performs sufficient DML action
|
|
--connect(con1,localhost,root,,test)
|
|
--connection con1
|
|
|
|
create table t1(
|
|
keyc int,
|
|
c1 char(255),
|
|
c2 char(255),
|
|
c3 char(255),
|
|
c4 char(255),
|
|
c5 char(255),
|
|
c6 char(255),
|
|
primary key(keyc)) engine = innodb;
|
|
|
|
delimiter |;
|
|
CREATE PROCEDURE populate_t1()
|
|
BEGIN
|
|
DECLARE i INT DEFAULT 1;
|
|
while (i <= 20000) DO
|
|
insert into t1 values (i, 'a', 'b', 'c', 'd', 'e', 'f' );
|
|
SET i = i + 1;
|
|
END WHILE;
|
|
END |
|
|
delimiter ;|
|
|
|
|
call populate_t1();
|
|
delete from t1 where keyc < 10000;
|
|
update t1 set c1 = 'mysql' where keyc > 10000;
|
|
update t1 set c2 = 'mysql' where keyc > 10000;
|
|
update t1 set c3= 'mysql' where keyc > 10000;
|
|
update t1 set c4= 'mysql' where keyc > 10000;
|
|
update t1 set c5= 'mysql' where keyc > 10000;
|
|
update t1 set c6= 'mysql' where keyc > 10000;
|
|
|
|
# Starting a new transaction for both tablespaces to get utilized
|
|
--connect(con2,localhost,root,,test)
|
|
--connection con2
|
|
|
|
create table t2 (
|
|
keyc int,
|
|
c1 char(255),
|
|
c2 char(255),
|
|
c3 char(255),
|
|
c4 char(255),
|
|
c5 char(255),
|
|
c6 char(255),
|
|
primary key(keyc)) engine = innodb;
|
|
|
|
delimiter |;
|
|
CREATE PROCEDURE populate_t2()
|
|
BEGIN
|
|
DECLARE i INT DEFAULT 1;
|
|
while (i <= 20000) DO
|
|
insert into t2 values (i, 'a', 'b', 'c', 'd', 'e', 'f' );
|
|
SET i = i + 1;
|
|
END WHILE;
|
|
END |
|
|
delimiter ;|
|
|
|
|
call populate_t2();
|
|
delete from t2 where keyc < 10000;
|
|
update t2 set c1 = 'mysql' where keyc > 10000;
|
|
update t2 set c2 = 'mysql' where keyc > 10000;
|
|
update t2 set c3= 'mysql' where keyc > 10000;
|
|
update t2 set c4= 'mysql' where keyc > 10000;
|
|
update t2 set c5= 'mysql' where keyc > 10000;
|
|
update t2 set c6= 'mysql' where keyc > 10000;
|
|
|
|
--connection default
|
|
|
|
# Cleanup
|
|
drop PROCEDURE populate_t1;
|
|
drop PROCEDURE populate_t2;
|
|
drop table t1, t2;
|
|
--disconnect con1
|
|
--disconnect con2
|
|
|
|
# Creating a file check.txt to record information about tablespace sizes
|
|
let CHECKFILE = $MYSQLTEST_VARDIR/tmp/check.txt;
|
|
|
|
# Storing the sizes of both tablespaces before server shutdown
|
|
perl;
|
|
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$before1)
|
|
= stat("$ENV{MYSQLD_DATADIR}/undo_001");
|
|
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$before2)
|
|
= stat("$ENV{MYSQLD_DATADIR}/undo_002");
|
|
open(OUT, ">$ENV{CHECKFILE}") || die;
|
|
print OUT "let \$before1= $before1;\n";
|
|
print OUT "let \$before2= $before2;\n";
|
|
close(OUT);
|
|
EOF
|
|
|
|
# Sourcing file check.txt to compare initial sizes with sizes after DML action
|
|
--source $CHECKFILE
|
|
|
|
if($init1 == $before1)
|
|
{
|
|
echo Size increase did not happen for undo_001: Initial Size: $init1 Before shutdown: $before1;
|
|
}
|
|
if($init2 == $before2)
|
|
{
|
|
echo Size increase did not happen for undo_002: Initial Size: $init2 Before shutdown: $before2;
|
|
}
|
|
|
|
SET GLOBAL innodb_purge_run_now=ON;
|
|
|
|
# Shutting down the server
|
|
SET GLOBAL innodb_fast_shutdown=0;
|
|
--let $shutdown_server_timeout= 300
|
|
--source include/shutdown_mysqld.inc
|
|
|
|
# Storing the sizes of both tablespaces after server shutdown
|
|
perl;
|
|
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$after1)
|
|
= stat("$ENV{MYSQLD_DATADIR}/undo_001");
|
|
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$after2)
|
|
= stat("$ENV{MYSQLD_DATADIR}/undo_002");
|
|
open(OUT, ">$ENV{CHECKFILE}") || die;
|
|
print OUT "let \$after1= $after1;\n";
|
|
print OUT "let \$after2= $after2;\n";
|
|
close(OUT);
|
|
EOF
|
|
|
|
# Sourcing the file to check whether truncation happened
|
|
--source $CHECKFILE
|
|
|
|
# Checking the sizes before and after the server shutdown
|
|
if ($after1 != $init1)
|
|
{
|
|
echo After Truncation size is wrong for undo_001: Initial Size: $init1 Before shutdown: $before1 After shutdown: $after1;
|
|
}
|
|
if ($after2 != $init2)
|
|
{
|
|
echo After Truncation size is wrong for undo_002: Initial Size: $init2 Before shutdown: $before2 After shutdown: $after2;
|
|
}
|
|
|
|
--echo #
|
|
--echo # Cleanup
|
|
--echo #
|
|
|
|
--let $restart_parameters=
|
|
--source include/start_mysqld.inc
|
|
--remove_file $CHECKFILE
|