1# 2# WL#6560: InnoDB: separate tablespace for innodb-temp-tables. 3# 4 5--source include/have_innodb.inc 6--source include/have_debug.inc 7 8# Valgrind can hang or return spurious messages on DBUG_SUICIDE 9--source include/not_valgrind.inc 10# Embedded server does not support crashing 11--source include/not_embedded.inc 12# Avoid CrashReporter popup on Mac 13--source include/not_crashrep.inc 14 15--source include/have_innodb_max_16k.inc 16 17# In the test scenario, there can be orphaned .frm files. 18# These are expected. So suppressing the associated warnings. 19call mtr.add_suppression("\\[ERROR\\] InnoDB: table .* does not exist " 20 "in the InnoDB internal"); 21 22################################################################################ 23# 24# Will test following scenarios: 25# 1. hit a crash point during tablespace creation to ensure temp-table 26# is recovered correctly. 27# 2. hit a crash point during table creation. 28# 3. hit a crash point during tablespace expansion. 29# 4. hit a crash point while appying log 30# 31################################################################################ 32 33#----------------------------------------------------------------------------- 34# 35# create test-bed 36# 37set global innodb_file_per_table = off; 38let $MYSQL_TMP_DIR = `select @@tmpdir`; 39let $MYSQL_DATA_DIR = `select @@datadir`; 40let SEARCH_FILE = $MYSQLTEST_VARDIR/log/my_restart.err; 41let $args = --loose-console > $SEARCH_FILE 2>&1; 42let crash = $args --innodb-force-recovery-crash; 43 44#----------------------------------------------------------------------------- 45# 46# 1. hit a crash point during tablespace creation to ensure temp-table 47# is recovered correctly. 48# 49--echo "testing creation of tablepsace by enabling error path" 50--echo # files in MYSQL_DATA_DIR 51--list_files $MYSQL_DATA_DIR/ ibtmp* 52# 53--source include/shutdown_mysqld.inc 54# 55--echo "Temp-tablespace removed on shutdown" 56--echo # files in MYSQL_DATA_DIR 57--list_files $MYSQL_DATA_DIR/ ibtmp* 58--echo --innodb-force-recovery-crash=100 59--echo "Next stmt will crash server" 60--error 137,3 61--exec $MYSQLD_CMD $crash=100 62let SEARCH_PATTERN = InnoDB: Creating shared tablespace for temporary tables; 63--source include/search_pattern_in_file.inc 64# Remove the separate doublewrite buffer from the crashed instance as we 65# are making the instance clean manually 66--remove_file $MYSQL_DATA_DIR/xb_doublewrite 67# 68--source include/start_mysqld.inc 69--echo # files in MYSQL_DATA_DIR 70--list_files $MYSQL_DATA_DIR/ ibtmp* 71create temporary table t1 (keyc int, c1 char(100), c2 char(100)) engine=innodb; 72insert into t1 values (1, 'c', 'b'); 73select * from t1; 74drop table t1; 75 76#----------------------------------------------------------------------------- 77# 78# 2. hit a crash point during table creation. 79# 80--echo "try hitting crash-point during table creation" 81--echo # files in MYSQL_DATA_DIR 82--list_files $MYSQL_DATA_DIR/ ibtmp* 83--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect 84set session debug="+d,ib_ddl_crash_during_create2"; 85--error 2013 86create temporary table t1 87 (a int, b int, primary key(a), index(b)) engine = innodb; 88--enable_reconnect 89--source include/wait_until_connected_again.inc 90--disable_reconnect 91--echo # files in MYSQL_DATA_DIR 92--list_files $MYSQL_DATA_DIR/ ibtmp* 93create temporary table t1 94 (a int, b int, primary key(a), index(b)) engine = innodb; 95insert into t1 values (1, 2); 96select * from t1; 97drop table t1; 98 99#----------------------------------------------------------------------------- 100# 101# 3. hit a crash point during tablespace expansion. 102# 103set session debug="-d,ib_ddl_crash_during_create"; 104use test; 105create temporary table t1 106 (a int, b char(100), c char(100)) engine = innodb; 107create table t2 108 (a int, b char(100), c char(100)) engine = innodb; 109delimiter |; 110create procedure populate_t1_t2() 111begin 112 declare i int default 1; 113 while (i <= 5000) DO 114 insert into t1 values (i, 'a', 'b'); 115 insert into t2 values (i, 'a', 'b'); 116 set i = i + 1; 117 end while; 118end| 119delimiter ;| 120set autocommit = 0; 121--disable_query_log 122call populate_t1_t2(); 123--echo # set debug point ib_crash_during_tablespace_extension 124--enable_query_log 125set session debug="+d,ib_crash_during_tablespace_extension"; 126select count(*) from t1; 127select count(*) from t2; 128commit; 129show tables; 130select count(*) from t1; 131select count(*) from t2; 132--echo # stnt will result in tablespace extension 133--exec echo "restart " > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect 134--error 2013 135call populate_t1_t2(); 136# 137--enable_reconnect 138# Write file to make mysql-test-run.pl start up the server again 139--source include/wait_until_connected_again.inc 140--disable_reconnect 141# 142use test; 143show tables; 144select count(*) from t2; 145select * from t2 limit 10; 146set autocommit = 1; 147truncate table t2; 148select count(*) from t2; 149# 150drop procedure populate_t1_t2; 151drop table t2; 152 153 154#----------------------------------------------------------------------------- 155# 156# 4. hit a crash point while appying log 157# 158use test; 159create temporary table t1 160 (a int, b char(100), c char(100)) engine = innodb; 161create table t2 162 (a int, b char(100), c char(100)) engine = innodb; 163insert into t1 values (1, 'a', 'b'); 164insert into t2 values (1, 'a', 'b'); 165select * from t1; 166select * from t2; 167set session debug="+d,crash_commit_after"; 168--exec echo "restart " > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect 169--error 2013 170insert into t2 values (2, 'a', 'b'); 171# 172--enable_reconnect 173# Write file to make mysql-test-run.pl start up the server again 174--source include/wait_until_connected_again.inc 175--disable_reconnect 176use test; 177show tables; 178select * from t2; 179insert into t2 values (3, 'a', 'b'); 180select * from t2; 181# 182create temporary table t1 183 (a int, b char(100), c char(100)) engine = innodb; 184insert into t1 values (1, 'a', 'b'); 185begin; 186insert into t2 values (4, 'a', 'b'); 187--source include/kill_and_restart_mysqld.inc 188show tables; 189select * from t2; 190update t2 set a = a * -1; 191select * from t2 order by a; 192# 193create temporary table t1 194 (a int, b char(100), c char(100)) engine = innodb; 195insert into t1 values (1, 'a', 'b'); 196begin; 197insert into t1 values (4, 'a', 'b'); 198# crash on temp table commit_before 199--source include/kill_and_restart_mysqld.inc 200show tables; 201SELECT * from t2; 202update t2 set a = a * -1; 203SELECT * from t2 order by a; 204# 205drop table t2; 206