Current Path : /home/usr.opt/mysql57/mysql-test/suite/innodb_zip/t/ |
FreeBSD hs32.drive.ne.jp 9.1-RELEASE FreeBSD 9.1-RELEASE #1: Wed Jan 14 12:18:08 JST 2015 root@hs32.drive.ne.jp:/sys/amd64/compile/hs32 amd64 |
Current File : //home/usr.opt/mysql57/mysql-test/suite/innodb_zip/t/wl6501.test |
# # WL#6501: make truncate table atomic # --source include/have_innodb.inc --source include/have_innodb_zip.inc --source include/have_debug.inc --source include/have_debug_sync.inc --source include/not_windows.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 ################################################################################ # # Will test following scenarios: # 1. Test some basic dml action involving truncate of table. # 2. Test that truncating reference table is blocked. # 3. Test truncate of loaded table that has blob + compression. # 4. Compressed table with small key-block-size. # 5. Check truncate with lock/unlock # 6. Crash after magic-value to truncate log but before deleting the file. # 7. Log checkpoint in between and then crash to see if server is able to # recover successfully. # 8. OOM error/File writing error while writing truncate log. # 9. Failure before flushing the truncate log but immediate after writing it. # 10. Test for concurrent truncate. # 11. Crash after truncate is complete. # 12. Multiple MLOG_TRUNCATE log records. # 13. Crash during truncate of fts should help mark fts table corrupt. # ################################################################################ #----------------------------------------------------------------------------- # # create test-bed # let $MYSQL_TMP_DIR = `select @@tmpdir`; let $MYSQL_DATA_DIR = `select @@datadir`; let SEARCH_FILE = $MYSQLTEST_VARDIR/log/my_restart.err; --disable_query_log # suppress expected warnings. call mtr.add_suppression("Have you deleted or moved.*"); call mtr.add_suppression("Failed to open truncate log file"); call mtr.add_suppression("Parent table of FTS auxiliary table"); call mtr.add_suppression("\\[ERROR\\] InnoDB: Operating system error number .* in a file operation"); call mtr.add_suppression("\\[ERROR\\] InnoDB: The error means that another program is using InnoDB's files"); call mtr.add_suppression("\\[ERROR\\] InnoDB: The error means the system cannot find the path specified."); call mtr.add_suppression("\\[ERROR\\] InnoDB: Cannot open datafile for read-only"); call mtr.add_suppression("\\[ERROR\\] InnoDB: Could not find a valid tablespace file for"); call mtr.add_suppression("\\[ERROR\\] InnoDB: File .*s_def.ibd: 'delete' returned OS error [0-9]*"); call mtr.add_suppression("\\[ERROR\\] InnoDB: Attempted to open a previously opened tablespace. Previous tablespace innodb_general_[0-9]* at filepath: .*s1.ibd uses space ID: [0-9]*. Cannot open filepath: .*s1.ibd which uses the same space ID."); call mtr.add_suppression("\\[ERROR\\] InnoDB: If you are installing InnoDB, remember that you must create directories yourself, InnoDB does not create them."); call mtr.add_suppression("\\[ERROR\\] InnoDB: Failed to find tablespace for table"); call mtr.add_suppression("\\[Warning\\] InnoDB: Ignoring tablespace "); call mtr.add_suppression("\\[ERROR\\] InnoDB: Flagged corruption of .* in FTS_SANITY_CHECK"); call mtr.add_suppression("\\[Warning\\] InnoDB: Cannot open table .* from the internal data dictionary of InnoDB though the .frm file for the table exists.*"); --enable_query_log #----------------------------------------------------------------------------- # # 1. Test some basic dml action involving truncate of table. # --echo "1. Test some basic dml action involving truncate of table." use test; set global innodb_file_per_table = 0; create table t1 (keyc int, c1 char(100), c2 char(100), primary key(keyc), index sec_index(c1) ) engine = innodb; create table t2 (keyc int, c1 char(100), c2 char(100), primary key(keyc), index sec_index(c1) ) engine = innodb; --source suite/innodb_zip/include/innodb_dml_ops.inc drop table t1; drop table t2; # create temporary table t1 (keyc int, c1 char(100), c2 char(100), primary key(keyc), index sec_index(c1) ) engine = innodb; create temporary table t2 (keyc int, c1 char(100), c2 char(100), primary key(keyc), index sec_index(c1) ) engine = innodb; --source suite/innodb_zip/include/innodb_dml_ops.inc drop table t1; drop table t2; # set global innodb_file_per_table = 1; create table t1 (keyc int, c1 char(100), c2 char(100), primary key(keyc), index sec_index(c1) ) engine = innodb; create table t2 (keyc int, c1 char(100), c2 char(100), primary key(keyc), index sec_index(c1) ) engine = innodb; --source suite/innodb_zip/include/innodb_dml_ops.inc drop table t1; drop table t2; # create temporary table t1 (keyc int, c1 char(100), c2 char(100), primary key(keyc), index sec_index(c1) ) engine = innodb; create temporary table t2 (keyc int, c1 char(100), c2 char(100), primary key(keyc), index sec_index(c1) ) engine = innodb; --source suite/innodb_zip/include/innodb_dml_ops.inc drop table t1; drop table t2; #----------------------------------------------------------------------------- # # 2. Test that truncating reference table is blocked. # --echo "2. Test that truncating reference table is blocked." use test; # create table master (i int, f float, c char(100), primary key pk(i), index fidx(f)) engine = innodb; # create table slave (i int, j int, primary key pk(i), foreign key fk(j) references master(i)) engine = innodb; # insert into master values (1, 1.1, 'a'), (2, 2.2, 'b'), (3, 3.3, 'c'), (4, 4.4, 'd'), (5, 5.5, 'e'); # insert into slave values (101, 1), (202, 3), (303, 5); # select * from master; select * from slave; # --error ER_TRUNCATE_ILLEGAL_FK truncate table master; # drop table slave; drop table master; #----------------------------------------------------------------------------- # # 3. Test truncate of loaded table that has blob + compression. # --echo "3. Test truncate of loaded table that has blob + compression." use test; # delimiter |; create procedure populate_t1() begin declare i int default 1; while (i <= 200) DO insert into t1 values (i, i, repeat(concat('tc3_', i), 1000), repeat('a', 1000)); set i = i + 1; end while; end| delimiter ;| # set global innodb_file_per_table = 0; create table t1 (a int not null, d int not null, b blob not null, c text, primary key (b(10), a, d), index (d), index(a), index (c(355), b(255)), index (b(5), c(10), a) ) engine=InnoDB; call populate_t1(); select count(*) from t1; # set session debug = "+d,ib_trunc_crash_before_log_removal"; --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --error 2013 truncate table t1; # --enable_reconnect --echo # Restart the MySQL server --source include/wait_until_connected_again.inc --disable_reconnect check table t1; select count(*) from t1; call populate_t1(); select count(*) from t1; drop table t1; # set innodb_strict_mode=off; --disable_warnings create table t1 (a int not null, d int not null, b blob not null, c text, primary key (b(10), a, d), index (d), index(a), index (c(355), b(255)), index (b(5), c(10), a) ) engine=InnoDB row_format=compressed key_block_size=8; --enable_warnings set innodb_strict_mode=default; call populate_t1(); select count(*) from t1; # set session debug = "+d,ib_trunc_crash_before_log_removal"; --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --error 2013 truncate table t1; # --enable_reconnect --echo # Restart the MySQL server --source include/wait_until_connected_again.inc --disable_reconnect check table t1; select count(*) from t1; call populate_t1(); select count(*) from t1; drop table t1; # drop procedure populate_t1; #----------------------------------------------------------------------------- # # 4. Compressed table with small key-block-size. # use test; SET sql_mode = 'NO_ENGINE_SUBSTITUTION'; delimiter |; create procedure populate_t1() begin declare i int default 1; while (i <= 200) DO insert into t1 values (i, i, repeat(concat('tc3_', i), 150), repeat('a', 100)); set i = i + 1; end while; end| delimiter ;| # set global innodb_file_per_table = 1; create table t1 (a int not null, d int not null, b varchar(198) not null, c char(185), unique key (b(10), a, d), index (d), index(a), index (c(120), b(120)), index (b(5), c(10), a)) engine=InnoDB stats_persistent=0 row_format=compressed key_block_size=1; # begin; call populate_t1(); commit; select count(*) from t1; SET sql_mode = default; # set session debug = "+d,ib_trunc_crash_before_log_removal"; --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --error 2013 truncate table t1; # --enable_reconnect --echo # Restart the MySQL server --source include/wait_until_connected_again.inc --disable_reconnect check table t1; select count(*) from t1; # begin; call populate_t1(); commit; select count(*) from t1; drop table t1; # set global innodb_file_per_table = 0; set global innodb_file_format = 'Antelope'; create table t1 (a int not null, d int not null, b varchar(198) not null, c char(185), unique key (b(10), a, d), index (d), index(a), index (c(120), b(120)), index (b(5), c(10), a)) engine=InnoDB stats_persistent=0; # begin; call populate_t1(); commit; select count(*) from t1; # set session debug = "+d,ib_trunc_crash_before_log_removal"; --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --error 2013 truncate table t1; # --enable_reconnect --echo # Restart the MySQL server --source include/wait_until_connected_again.inc --disable_reconnect check table t1; select count(*) from t1; # begin; call populate_t1(); commit; select count(*) from t1; drop table t1; # drop procedure populate_t1; #----------------------------------------------------------------------------- --echo "5 check truncate with lock/unlock" use test; set global innodb_file_per_table = 1; create table master (i int, f float, c char(100), primary key pk(i), index fidx(f)) engine = innodb; insert into master values (1, 1.1, 'a'), (2, 2.2, 'b'), (3, 3.3, 'c'), (4, 4.4, 'd'), (5, 5.5, 'e'); select * from master; --echo "--In con1 connection--" connect (con1,localhost,root,,); use test; lock tables master write; --echo "--In default connection--" connection default; use test; --send truncate table master; --echo "--In con1 connection--" connection con1; select * from master; unlock tables; disconnect con1; --echo "--In default connection--" connection default; --reap select * from master; drop table master; #----------------------------------------------------------------------------- # # 6. Crash after magic-value to truncate log but before deleting the file. # use test; set global innodb_file_per_table = 1; create table t1 (i int, f float, c char(100), primary key pk(i), index fidx(f)) engine = innodb; insert into t1 values (1, 1.1, 'a'), (2, 2.2, 'b'), (3, 3.3, 'c'), (4, 4.4, 'd'), (5, 5.5, 'e'); select * from t1; set session debug = "+d,ib_trunc_crash_after_logging_complete"; --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --error 2013 truncate table t1; --enable_reconnect --echo # Restart the MySQL server --source include/wait_until_connected_again.inc --disable_reconnect check table t1; select * from t1; insert into t1 values (1, 1.1, 'a'), (2, 2.2, 'b'), (3, 3.3, 'c'); select * from t1; drop table t1; #----------------------------------------------------------------------------- # # 7. Log checkpoint in between and then crash to see if server is able to # recover successfully. # use test; set global innodb_file_per_table = 1; create table t1 (i int, f float, c char(100), primary key pk(i), index fidx(f)) engine = innodb; # insert into t1 values (1, 1.1, 'a'), (2, 2.2, 'b'), (3, 3.3, 'c'), (4, 4.4, 'd'), (5, 5.5, 'e'); select * from t1; set session debug = "+d,ib_trunc_crash_with_intermediate_log_checkpoint"; --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --error 2013 truncate table t1; # --enable_reconnect --echo # Restart the MySQL server --source include/wait_until_connected_again.inc --disable_reconnect select * from t1; drop table t1; #----------------------------------------------------------------------------- # # 8. OOM error while writing truncate log. # use test; create table t (i int, j int) engine=innodb; insert into t values (1,1), (2,2), (3,3); select * from t; set session debug="+d,ib_err_trunc_oom_logging"; --error ER_GET_ERRNO truncate table t; set session debug="-d,ib_err_trunc_oom_logging"; select * from t; # select * from t; set session debug="+d,ib_err_trunc_writing_magic_number"; truncate table t; select * from t; insert into t values (1,1), (2,2), (3,3); select * from t; # --echo # Restart the MySQL server --source include/restart_mysqld.inc # select * from t; drop table t; #----------------------------------------------------------------------------- # # 9. Failure before flushing the truncate log but immediate after writing it. # use test; create table t (i int, j int, primary key pk(i), index idx(j)) engine=innodb; insert into t values (1,1), (2,2), (3,3); select * from t; set session debug="+d,ib_trunc_crash_after_updating_magic_no"; --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --error 2013 truncate table t; # --enable_reconnect --echo # Restart the MySQL server --source include/wait_until_connected_again.inc --disable_reconnect # # truncate action should be complete as magic_number if already written select * from t; drop table t; #----------------------------------------------------------------------------- # # 10. Test for concurrent truncate. # use test; set global innodb_file_per_table = 0; create table t1 (i int, primary key pk(i)) engine=innodb; create table t2 (j int) engine=innodb; insert into t1 values (1), (2), (3), (4), (5); insert into t2 values (1), (2), (3), (4), (5); select * from t1; select * from t2; # connect (con1,localhost,root,,); connect (con2,localhost,root,,); # connection con1; use test; connection con2; use test; # connection con1; select * from t1; set DEBUG_SYNC='RESET'; set DEBUG_SYNC='ib_trunc_table_trunc_completing SIGNAL trunc_completing WAIT_FOR trunc_continue'; --send truncate table t1; # connection con2; set DEBUG_SYNC='now WAIT_FOR trunc_completing'; select * from t2; truncate table t2; select * from t2; set DEBUG_SYNC='now SIGNAL trunc_continue'; # connection con1; --reap select * from t1; # connection default; set DEBUG_SYNC='RESET'; disconnect con1; disconnect con2; drop table t1; drop table t2; #----------------------------------------------------------------------------- # # 11. Crash after truncate is complete. # use test; set global innodb_file_per_table = 1; create table t1 (a int, b char(100), c char(100)) engine = innodb; delimiter |; create procedure populate_t1() begin declare i int default 1; while (i <= 2000) DO insert into t1 values (i, 'a', 'b'); set i = i + 1; end while; end| delimiter ;| begin; call populate_t1(); commit; # set session debug="+d,ib_trunc_crash_after_truncate_done"; begin; update t1 set a = a + 1000; commit; # Statement above will generate redo and for crash post truncate # recovery should avoid applying these redo records. --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --error 2013 truncate table t1; # --enable_reconnect --echo # Restart the MySQL server --source include/wait_until_connected_again.inc --disable_reconnect # select count(*) from t1; # drop procedure populate_t1; drop table t1; #----------------------------------------------------------------------------- # # 12. Multiple MLOG_TRUNCATE log records. # use test; set global innodb_file_per_table = 1; create table t1 (a int, b char(100), c char(100)) engine = innodb; create table t2 (a int, b char(100), c char(100)) engine = innodb; create table t3 (a int, b char(100), c char(100)) engine = innodb; delimiter |; create procedure populate_t1() begin declare i int default 1; while (i <= 2000) DO insert into t1 values (i, 'a', 'b'); set i = i + 1; end while; end| create procedure populate_t2() begin declare i int default 1; while (i <= 2000) DO insert into t2 values (i, 'a', 'b'); set i = i + 1; end while; end| create procedure populate_t3() begin declare i int default 1; while (i <= 2000) DO insert into t3 values (i, 'a', 'b'); set i = i + 1; end while; end| delimiter ;| # begin; call populate_t1(); call populate_t2(); call populate_t3(); commit; # select count(*) from t1; truncate table t1; select count(*) from t1; select count(*) from t2; truncate table t2; select count(*) from t2; select count(*) from t3; --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect set session debug="+d,ib_trunc_crash_after_truncate_done"; --error 2013 truncate table t3; # --enable_reconnect --echo # Restart the MySQL server --source include/wait_until_connected_again.inc --disable_reconnect # select count(*) from t1; select count(*) from t2; select count(*) from t3; begin; call populate_t1(); call populate_t2(); call populate_t3(); commit; select count(*) from t1; select count(*) from t2; select count(*) from t3; # truncate table t1; truncate table t1; --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect set session debug="+d,ib_trunc_crash_after_truncate_done"; --error 2013 truncate table t1; # --enable_reconnect --echo # Restart the MySQL server --source include/wait_until_connected_again.inc --disable_reconnect # select count(*) from t1; # drop procedure populate_t1; drop procedure populate_t2; drop procedure populate_t3; drop table t1, t2, t3; #----------------------------------------------------------------------------- # # 13. Crash during truncate of fts should help mark fts table corrupt. # create table ibstd_33 ( a int not null, d varchar(40) not null, b text not null, c text, index(d), index(a), primary key (b(16), a, d), fulltext ftsic(c)) engine=InnoDB row_format=dynamic; # insert into ibstd_33 (a,d,b,c) values ('1','6', repeat('0.350557460150547arrclolullcocuraalaulloooclrcoulrccaoocourcrorooruruooauuauarrouccuoucrooaaouullrularcoarclloraaac','367'), repeat('0.0836047279001129oaalolrllcoulaoococrolooullocuaacocoaoloclouallruaalolaruucaloluraocorrlouuoaorloarrluaaorucu','534')); select count(*) from ibstd_33; # --source include/expect_crash.inc set session debug = "+d,ib_truncate_crash_while_fts_cleanup"; --error 2013 truncate table ibstd_33; # --source include/start_mysqld.inc # --error ER_NO_SUCH_TABLE select count(*) from ibstd_33; drop table ibstd_33; # Test with internal FTS_DOC_ID Index and then the truncate crash CREATE TABLE t1 (a VARCHAR(200), b TEXT, FULLTEXT INDEX ft1(a,b(200))) ENGINE = InnoDB; INSERT INTO t1 VALUES('MySQL has now support', 'for full-text search'), ('Full-text indexes', 'are called collections'), ('Only MyISAM tables','support collections'), ('Function MATCH ... AGAINST()','is used to do a search'), ('Full-text search in MySQL', 'implements vector space model'); select * from t1 where MATCH(a,b) AGAINST ("collections"); select * from t1 where MATCH(a,b) AGAINST ("indexes"); select * from t1 where MATCH(a,b) AGAINST ("indexes collections"); select * from t1 where MATCH(a,b) AGAINST ("only"); ALTER TABLE t1 DROP INDEX ft1; --source include/expect_crash.inc set session debug = "+d,ib_truncate_crash_while_fts_cleanup"; --error 2013 truncate table t1; --source include/start_mysqld.inc --error ER_NO_SUCH_TABLE INSERT INTO t1 VALUES('MySQL has now support', 'for full-text search'), ('Full-text indexes', 'are called collections'), ('Only MyISAM tables','support collections'), ('Function MATCH ... AGAINST()','is used to do a search'), ('Full-text search in MySQL', 'implements vector space model'); --error ER_NO_SUCH_TABLE select * from t1 where MATCH(a,b) AGAINST ("collections"); drop table t1; #----------------------------------------------------------------------------- # # remove test-bed # set global innodb_file_per_table = default; set global innodb_strict_mode = default;