Commit f25e9aa4 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-20310: Make InnoDB crash tests Valgrind-friendly

Use DEBUG_SYNC to hang the execution at the interesting point,
and then kill and restart the server externally. This will work
also with Valgrind. DBUG_SUICIDE() causes Valgrind to hang,
and it could also cause uninteresting reports about memory leaks.

While we are at it, let us clean up innodb.innodb_bulk_create_index_debug
so that it will actually test the desired functionality also in future
versions (with instant ADD COLUMN and DROP COLUMN) and avoid
some unnecessary restarts.

We are adding two DEBUG_SYNC points for ALTER TABLE, because there were
none that would be executed right before ha_commit_trans().
parent 5edc4ea4
......@@ -4,17 +4,8 @@
# Not supported in embedded
-- source include/not_embedded.inc
# This test case needs to crash the server. Needs a debug server.
-- source include/have_debug.inc
# Don't test this under valgrind, memory leaks will occur.
-- source include/not_valgrind.inc
# Avoid CrashReporter popup on Mac
-- source include/not_crashrep.inc
-- source include/have_innodb.inc
-- source include/have_debug_sync.inc
# Create Insert Procedure
DELIMITER |;
......@@ -62,21 +53,11 @@ CALL populate_t1();
SELECT COUNT(*) FROM t1;
--enable_info
CREATE INDEX idx_title ON t1(title);
--disable_info
--source include/restart_mysqld.inc
CHECK TABLE t1;
SELECT * FROM t1 WHERE title = 'a10';
SELECT * FROM t1 WHERE title = 'a5000';
SELECT * FROM t1 WHERE title = 'a10000';
SELECT * FROM t1 WHERE title = 'a10010';
DROP TABLE t1;
RENAME TABLE t1 TO t0;
-- echo # Test Blob
......@@ -104,16 +85,32 @@ INSERT INTO t1 VALUES
SELECT CHAR_LENGTH(b) FROM t1;
ALTER TABLE t1 DROP COLUMN c;
--enable_info
ALTER TABLE t1 DROP COLUMN c, FORCE;
--disable_info
--source include/restart_mysqld.inc
CHECK TABLE t1;
CHECK TABLE t0,t1;
SELECT CHAR_LENGTH(b) FROM t1;
DROP TABLE t1;
RENAME TABLE t0 to t1;
CHECK TABLE t1;
SELECT * FROM t1 WHERE title = 'a10';
SELECT * FROM t1 WHERE title = 'a5000';
SELECT * FROM t1 WHERE title = 'a10000';
SELECT * FROM t1 WHERE title = 'a10010';
DROP TABLE t1;
# Test Crash Recovery
if ($row_format != 'COMPRESSED')
......@@ -140,17 +137,16 @@ if ($row_format == 'COMPRESSED')
CALL populate_t1();
-- enable_query_log
SET debug_dbug='+d,crash_commit_before';
# Write file to make mysql-test-run.pl start up the server again
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--error 2013
connect (hang,localhost,root);
SET DEBUG_SYNC='alter_table_inplace_trans_commit SIGNAL hung WAIT_FOR ever';
send
CREATE INDEX idx_title ON t1(title);
--enable_reconnect
--source include/wait_until_connected_again.inc
--disable_reconnect
connection default;
SET DEBUG_SYNC='now WAIT_FOR hung';
let $shutdown_timeout=0;
--source include/restart_mysqld.inc
disconnect hang;
SELECT COUNT(*) FROM t1;
......@@ -194,17 +190,16 @@ INSERT INTO t1 VALUES
SELECT CHAR_LENGTH(b) FROM t1;
SET debug_dbug='+d,crash_commit_before';
# Write file to make mysql-test-run.pl start up the server again
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--error 2013
ALTER TABLE t1 DROP COLUMN c;
connect (hang,localhost,root);
SET DEBUG_SYNC='alter_table_inplace_trans_commit SIGNAL hung WAIT_FOR ever';
send
ALTER TABLE t1 DROP COLUMN c, FORCE;
--enable_reconnect
--source include/wait_until_connected_again.inc
--disable_reconnect
connection default;
SET DEBUG_SYNC='now WAIT_FOR hung';
--source include/restart_mysqld.inc
disconnect hang;
let $shutdown_timeout=60;
CHECK TABLE t1;
......@@ -212,10 +207,4 @@ SELECT CHAR_LENGTH(b) FROM t1;
DROP TABLE t1;
# Restore global variables
if ($row_format == 'COMPRESSED')
{
SET GLOBAL innodb_file_per_table=default;
}
DROP PROCEDURE populate_t1;
......@@ -37,7 +37,9 @@ t1 CREATE TABLE `t1` (
FULLTEXT KEY `b_2` (`b`,`c`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
ALTER TABLE t1 FORCE, ALGORITHM=COPY;
SET DEBUG_DBUG='+d,crash_commit_before';
connect hang,localhost,root;
SET DEBUG_SYNC='alter_table_copy_trans_commit SIGNAL hung WAIT_FOR ever';
# create 32 secondary indexes
ALTER TABLE t ADD INDEX(b,c,d,a),ADD INDEX(b,c,a,d),ADD INDEX(b,a,c,d),ADD INDEX(b,a,d,c),
ADD INDEX(b,d,a,c),ADD INDEX(b,d,c,a),ADD INDEX(a,b,c,d),ADD INDEX(a,b,d,c),
ADD INDEX(a,c,b,d),ADD INDEX(a,c,d,b),ADD INDEX(a,d,b,c),ADD INDEX(a,d,c,b),
......@@ -47,7 +49,9 @@ ADD INDEX(d,b,a,c),ADD INDEX(d,b,c,a),ADD INDEX(d,c,a,b),ADD INDEX(d,c,b,a),
ADD INDEX(a,b,c), ADD INDEX(a,c,b), ADD INDEX(a,c,d), ADD INDEX(a,d,c),
ADD INDEX(a,b,d), ADD INDEX(a,d,b), ADD INDEX(b,c,d), ADD INDEX(b,d,c),
ALGORITHM=COPY;
ERROR HY000: Lost connection to MySQL server during query
connection default;
SET DEBUG_SYNC='now WAIT_FOR hung';
disconnect hang;
#sql-temporary.frm
#sql-temporary.ibd
FTS_INDEX_1.ibd
......
......@@ -17,21 +17,9 @@ SELECT COUNT(*) FROM t1;
COUNT(*)
10000
CREATE INDEX idx_title ON t1(title);
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1 WHERE title = 'a10';
class id title
10 10 a10
SELECT * FROM t1 WHERE title = 'a5000';
class id title
5000 5000 a5000
SELECT * FROM t1 WHERE title = 'a10000';
class id title
10000 10000 a10000
SELECT * FROM t1 WHERE title = 'a10010';
class id title
DROP TABLE t1;
affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 0
RENAME TABLE t1 TO t0;
# Test Blob
CREATE TABLE t1(
a INT PRIMARY KEY,
......@@ -48,9 +36,12 @@ CHAR_LENGTH(b)
20000
40000
60000
ALTER TABLE t1 DROP COLUMN c;
CHECK TABLE t1;
ALTER TABLE t1 DROP COLUMN c, FORCE;
affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 0
CHECK TABLE t0,t1;
Table Op Msg_type Msg_text
test.t0 check status OK
test.t1 check status OK
SELECT CHAR_LENGTH(b) FROM t1;
CHAR_LENGTH(b)
......@@ -59,14 +50,33 @@ CHAR_LENGTH(b)
40000
60000
DROP TABLE t1;
RENAME TABLE t0 to t1;
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1 WHERE title = 'a10';
class id title
10 10 a10
SELECT * FROM t1 WHERE title = 'a5000';
class id title
5000 5000 a5000
SELECT * FROM t1 WHERE title = 'a10000';
class id title
10000 10000 a10000
SELECT * FROM t1 WHERE title = 'a10010';
class id title
DROP TABLE t1;
CREATE TABLE t1(
class INT,
id INT,
title VARCHAR(100)
) ENGINE=InnoDB ROW_FORMAT=REDUNDANT;
SET debug_dbug='+d,crash_commit_before';
connect hang,localhost,root;
SET DEBUG_SYNC='alter_table_inplace_trans_commit SIGNAL hung WAIT_FOR ever';
CREATE INDEX idx_title ON t1(title);
ERROR HY000: Lost connection to MySQL server during query
connection default;
SET DEBUG_SYNC='now WAIT_FOR hung';
disconnect hang;
SELECT COUNT(*) FROM t1;
COUNT(*)
10000
......@@ -104,9 +114,12 @@ CHAR_LENGTH(b)
20000
40000
60000
SET debug_dbug='+d,crash_commit_before';
ALTER TABLE t1 DROP COLUMN c;
ERROR HY000: Lost connection to MySQL server during query
connect hang,localhost,root;
SET DEBUG_SYNC='alter_table_inplace_trans_commit SIGNAL hung WAIT_FOR ever';
ALTER TABLE t1 DROP COLUMN c, FORCE;
connection default;
SET DEBUG_SYNC='now WAIT_FOR hung';
disconnect hang;
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
......@@ -137,21 +150,9 @@ SELECT COUNT(*) FROM t1;
COUNT(*)
10000
CREATE INDEX idx_title ON t1(title);
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1 WHERE title = 'a10';
class id title
10 10 a10
SELECT * FROM t1 WHERE title = 'a5000';
class id title
5000 5000 a5000
SELECT * FROM t1 WHERE title = 'a10000';
class id title
10000 10000 a10000
SELECT * FROM t1 WHERE title = 'a10010';
class id title
DROP TABLE t1;
affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 0
RENAME TABLE t1 TO t0;
# Test Blob
CREATE TABLE t1(
a INT PRIMARY KEY,
......@@ -168,9 +169,12 @@ CHAR_LENGTH(b)
20000
40000
60000
ALTER TABLE t1 DROP COLUMN c;
CHECK TABLE t1;
ALTER TABLE t1 DROP COLUMN c, FORCE;
affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 0
CHECK TABLE t0,t1;
Table Op Msg_type Msg_text
test.t0 check status OK
test.t1 check status OK
SELECT CHAR_LENGTH(b) FROM t1;
CHAR_LENGTH(b)
......@@ -179,14 +183,33 @@ CHAR_LENGTH(b)
40000
60000
DROP TABLE t1;
RENAME TABLE t0 to t1;
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1 WHERE title = 'a10';
class id title
10 10 a10
SELECT * FROM t1 WHERE title = 'a5000';
class id title
5000 5000 a5000
SELECT * FROM t1 WHERE title = 'a10000';
class id title
10000 10000 a10000
SELECT * FROM t1 WHERE title = 'a10010';
class id title
DROP TABLE t1;
CREATE TABLE t1(
class INT,
id INT,
title VARCHAR(100)
) ENGINE=InnoDB ROW_FORMAT=COMPACT;
SET debug_dbug='+d,crash_commit_before';
connect hang,localhost,root;
SET DEBUG_SYNC='alter_table_inplace_trans_commit SIGNAL hung WAIT_FOR ever';
CREATE INDEX idx_title ON t1(title);
ERROR HY000: Lost connection to MySQL server during query
connection default;
SET DEBUG_SYNC='now WAIT_FOR hung';
disconnect hang;
SELECT COUNT(*) FROM t1;
COUNT(*)
10000
......@@ -224,9 +247,12 @@ CHAR_LENGTH(b)
20000
40000
60000
SET debug_dbug='+d,crash_commit_before';
ALTER TABLE t1 DROP COLUMN c;
ERROR HY000: Lost connection to MySQL server during query
connect hang,localhost,root;
SET DEBUG_SYNC='alter_table_inplace_trans_commit SIGNAL hung WAIT_FOR ever';
ALTER TABLE t1 DROP COLUMN c, FORCE;
connection default;
SET DEBUG_SYNC='now WAIT_FOR hung';
disconnect hang;
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
......@@ -257,21 +283,9 @@ SELECT COUNT(*) FROM t1;
COUNT(*)
10000
CREATE INDEX idx_title ON t1(title);
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1 WHERE title = 'a10';
class id title
10 10 a10
SELECT * FROM t1 WHERE title = 'a5000';
class id title
5000 5000 a5000
SELECT * FROM t1 WHERE title = 'a10000';
class id title
10000 10000 a10000
SELECT * FROM t1 WHERE title = 'a10010';
class id title
DROP TABLE t1;
affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 0
RENAME TABLE t1 TO t0;
# Test Blob
CREATE TABLE t1(
a INT PRIMARY KEY,
......@@ -288,9 +302,12 @@ CHAR_LENGTH(b)
20000
40000
60000
ALTER TABLE t1 DROP COLUMN c;
CHECK TABLE t1;
ALTER TABLE t1 DROP COLUMN c, FORCE;
affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 0
CHECK TABLE t0,t1;
Table Op Msg_type Msg_text
test.t0 check status OK
test.t1 check status OK
SELECT CHAR_LENGTH(b) FROM t1;
CHAR_LENGTH(b)
......@@ -299,14 +316,33 @@ CHAR_LENGTH(b)
40000
60000
DROP TABLE t1;
RENAME TABLE t0 to t1;
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1 WHERE title = 'a10';
class id title
10 10 a10
SELECT * FROM t1 WHERE title = 'a5000';
class id title
5000 5000 a5000
SELECT * FROM t1 WHERE title = 'a10000';
class id title
10000 10000 a10000
SELECT * FROM t1 WHERE title = 'a10010';
class id title
DROP TABLE t1;
CREATE TABLE t1(
class INT,
id INT,
title VARCHAR(100)
) ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
SET debug_dbug='+d,crash_commit_before';
connect hang,localhost,root;
SET DEBUG_SYNC='alter_table_inplace_trans_commit SIGNAL hung WAIT_FOR ever';
CREATE INDEX idx_title ON t1(title);
ERROR HY000: Lost connection to MySQL server during query
connection default;
SET DEBUG_SYNC='now WAIT_FOR hung';
disconnect hang;
SELECT COUNT(*) FROM t1;
COUNT(*)
10000
......@@ -344,9 +380,12 @@ CHAR_LENGTH(b)
20000
40000
60000
SET debug_dbug='+d,crash_commit_before';
ALTER TABLE t1 DROP COLUMN c;
ERROR HY000: Lost connection to MySQL server during query
connect hang,localhost,root;
SET DEBUG_SYNC='alter_table_inplace_trans_commit SIGNAL hung WAIT_FOR ever';
ALTER TABLE t1 DROP COLUMN c, FORCE;
connection default;
SET DEBUG_SYNC='now WAIT_FOR hung';
disconnect hang;
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
......@@ -378,21 +417,9 @@ SELECT COUNT(*) FROM t1;
COUNT(*)
10000
CREATE INDEX idx_title ON t1(title);
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1 WHERE title = 'a10';
class id title
10 10 a10
SELECT * FROM t1 WHERE title = 'a5000';
class id title
5000 5000 a5000
SELECT * FROM t1 WHERE title = 'a10000';
class id title
10000 10000 a10000
SELECT * FROM t1 WHERE title = 'a10010';
class id title
DROP TABLE t1;
affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 0
RENAME TABLE t1 TO t0;
# Test Blob
SET GLOBAL innodb_file_per_table=1;
CREATE TABLE t1(
......@@ -410,9 +437,12 @@ CHAR_LENGTH(b)
20000
40000
60000
ALTER TABLE t1 DROP COLUMN c;
CHECK TABLE t1;
ALTER TABLE t1 DROP COLUMN c, FORCE;
affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 0
CHECK TABLE t0,t1;
Table Op Msg_type Msg_text
test.t0 check status OK
test.t1 check status OK
SELECT CHAR_LENGTH(b) FROM t1;
CHAR_LENGTH(b)
......@@ -421,15 +451,34 @@ CHAR_LENGTH(b)
40000
60000
DROP TABLE t1;
RENAME TABLE t0 to t1;
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT * FROM t1 WHERE title = 'a10';
class id title
10 10 a10
SELECT * FROM t1 WHERE title = 'a5000';
class id title
5000 5000 a5000
SELECT * FROM t1 WHERE title = 'a10000';
class id title
10000 10000 a10000
SELECT * FROM t1 WHERE title = 'a10010';
class id title
DROP TABLE t1;
SET GLOBAL innodb_file_per_table=1;
CREATE TABLE t1(
class INT,
id INT,
title VARCHAR(100)
) ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4;
SET debug_dbug='+d,crash_commit_before';
connect hang,localhost,root;
SET DEBUG_SYNC='alter_table_inplace_trans_commit SIGNAL hung WAIT_FOR ever';
CREATE INDEX idx_title ON t1(title);
ERROR HY000: Lost connection to MySQL server during query
connection default;
SET DEBUG_SYNC='now WAIT_FOR hung';
disconnect hang;
SELECT COUNT(*) FROM t1;
COUNT(*)
10000
......@@ -468,9 +517,12 @@ CHAR_LENGTH(b)
20000
40000
60000
SET debug_dbug='+d,crash_commit_before';
ALTER TABLE t1 DROP COLUMN c;
ERROR HY000: Lost connection to MySQL server during query
connect hang,localhost,root;
SET DEBUG_SYNC='alter_table_inplace_trans_commit SIGNAL hung WAIT_FOR ever';
ALTER TABLE t1 DROP COLUMN c, FORCE;
connection default;
SET DEBUG_SYNC='now WAIT_FOR hung';
disconnect hang;
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
......@@ -481,5 +533,4 @@ CHAR_LENGTH(b)
40000
60000
DROP TABLE t1;
SET GLOBAL innodb_file_per_table=default;
DROP PROCEDURE populate_t1;
......@@ -37,11 +37,11 @@ SELECT * FROM t1 WHERE MATCH(b,c) AGAINST ('column');
SHOW CREATE TABLE t1;
ALTER TABLE t1 FORCE, ALGORITHM=COPY;
# crash right after the last write_row(), before the first commit of ALTER TABLE
--source include/expect_crash.inc
# kill right after the last write_row(), before the first commit of ALTER TABLE
connect (hang,localhost,root);
SET DEBUG_DBUG='+d,crash_commit_before';
--error 2013
SET DEBUG_SYNC='alter_table_copy_trans_commit SIGNAL hung WAIT_FOR ever';
send
# create 32 secondary indexes
ALTER TABLE t ADD INDEX(b,c,d,a),ADD INDEX(b,c,a,d),ADD INDEX(b,a,c,d),ADD INDEX(b,a,d,c),
ADD INDEX(b,d,a,c),ADD INDEX(b,d,c,a),ADD INDEX(a,b,c,d),ADD INDEX(a,b,d,c),
......@@ -53,8 +53,13 @@ ALTER TABLE t ADD INDEX(b,c,d,a),ADD INDEX(b,c,a,d),ADD INDEX(b,a,c,d),ADD INDEX
ADD INDEX(a,b,d), ADD INDEX(a,d,b), ADD INDEX(b,c,d), ADD INDEX(b,d,c),
ALGORITHM=COPY;
connection default;
SET DEBUG_SYNC='now WAIT_FOR hung';
let $shutdown_timeout=0;
--let $restart_parameters= --innodb-force-recovery=3
--source include/start_mysqld.inc
--source include/restart_mysqld.inc
disconnect hang;
let $shutdown_timeout=;
let $datadir=`select @@datadir`;
--replace_regex /#sql-[0-9a-f_]*/#sql-temporary/ /FTS_[0-9a-f]*_[0-9a-f]*/FTS/
--list_files $datadir/test
......
......@@ -9788,6 +9788,7 @@ do_continue:;
(ulong) (copied + deleted), (ulong) deleted,
(ulong) thd->get_stmt_da()->current_statement_warn_count());
my_ok(thd, copied + deleted, 0L, alter_ctx.tmp_name);
DEBUG_SYNC(thd, "alter_table_inplace_trans_commit");
DBUG_RETURN(false);
err_new_table_cleanup:
......@@ -9889,12 +9890,14 @@ bool mysql_trans_commit_alter_copy_data(THD *thd)
uint save_unsafe_rollback_flags;
DBUG_ENTER("mysql_trans_commit_alter_copy_data");
/* Save flags as transcommit_implicit_are_deleting_them */
/* Save flags as trans_commit_implicit are deleting them */
save_unsafe_rollback_flags= thd->transaction.stmt.m_unsafe_rollback_flags;
DEBUG_SYNC(thd, "alter_table_copy_trans_commit");
if (ha_enable_transaction(thd, TRUE))
DBUG_RETURN(TRUE);
/*
Ensure that the new table is saved properly to disk before installing
the new .frm.
......
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