1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-26 07:02:12 +03:00
Files
mariadb/mysql-test/suite/innodb/include/innodb_bulk_create_index_debug.inc
Marko Mäkelä f25e9aa4ba 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().
2019-08-13 13:32:27 +03:00

211 lines
4.0 KiB
SQL

#
# wl#7277: InnoDB: Bulk Load for Create Index
#
# Not supported in embedded
-- source include/not_embedded.inc
-- source include/have_debug.inc
-- source include/have_debug_sync.inc
# Create Insert Procedure
DELIMITER |;
CREATE PROCEDURE populate_t1()
BEGIN
DECLARE i int DEFAULT 1;
START TRANSACTION;
WHILE (i <= 10000) DO
INSERT INTO t1 VALUES (i, i, CONCAT('a', i));
SET i = i + 1;
END WHILE;
COMMIT;
END|
DELIMITER ;|
# Test scenarios:
# 1. Test restart;
# 2. Test crash recovery.
# Test Restart
if ($row_format != 'COMPRESSED')
{
eval CREATE TABLE t1(
class INT,
id INT,
title VARCHAR(100)
) ENGINE=InnoDB ROW_FORMAT=$row_format;
}
if ($row_format == 'COMPRESSED')
{
SET GLOBAL innodb_file_per_table=1;
eval CREATE TABLE t1(
class INT,
id INT,
title VARCHAR(100)
) ENGINE=InnoDB ROW_FORMAT=$row_format KEY_BLOCK_SIZE=4;
}
-- disable_query_log
CALL populate_t1();
-- enable_query_log
SELECT COUNT(*) FROM t1;
--enable_info
CREATE INDEX idx_title ON t1(title);
--disable_info
RENAME TABLE t1 TO t0;
-- echo # Test Blob
if ($row_format != 'COMPRESSED') {
eval CREATE TABLE t1(
a INT PRIMARY KEY,
b TEXT,
c TEXT) ENGINE=InnoDB ROW_FORMAT=$row_format;
}
if ($row_format == 'COMPRESSED') {
SET GLOBAL innodb_file_per_table=1;
eval CREATE TABLE t1(
a INT PRIMARY KEY,
b TEXT,
c TEXT) ENGINE=InnoDB ROW_FORMAT=$row_format KEY_BLOCK_SIZE=4;
}
INSERT INTO t1 VALUES
(1, REPEAT('a',10000), 'a'),
(2, REPEAT('b',20000), 'b'),
(3, REPEAT('c',40000), 'c'),
(4, REPEAT('d',60000), 'd');
SELECT CHAR_LENGTH(b) FROM t1;
--enable_info
ALTER TABLE t1 DROP COLUMN c, FORCE;
--disable_info
--source include/restart_mysqld.inc
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')
{
eval CREATE TABLE t1(
class INT,
id INT,
title VARCHAR(100)
) ENGINE=InnoDB ROW_FORMAT=$row_format;
}
if ($row_format == 'COMPRESSED')
{
SET GLOBAL innodb_file_per_table=1;
eval CREATE TABLE t1(
class INT,
id INT,
title VARCHAR(100)
) ENGINE=InnoDB ROW_FORMAT=$row_format KEY_BLOCK_SIZE=4;
}
-- disable_query_log
CALL populate_t1();
-- enable_query_log
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);
connection default;
SET DEBUG_SYNC='now WAIT_FOR hung';
let $shutdown_timeout=0;
--source include/restart_mysqld.inc
disconnect hang;
SELECT COUNT(*) FROM t1;
CHECK TABLE t1;
EXPLAIN SELECT * FROM t1 WHERE title = 'a10';
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;
-- echo # Test Blob
if ($row_format != 'COMPRESSED') {
eval CREATE TABLE t1(
a INT PRIMARY KEY,
b TEXT,
c TEXT) ENGINE=InnoDB ROW_FORMAT=$row_format;
}
if ($row_format == 'COMPRESSED') {
SET GLOBAL innodb_file_per_table=1;
eval CREATE TABLE t1(
a INT PRIMARY KEY,
b TEXT,
c TEXT) ENGINE=InnoDB ROW_FORMAT=$row_format KEY_BLOCK_SIZE=4;
}
INSERT INTO t1 VALUES
(1, REPEAT('a',10000), 'a'),
(2, REPEAT('b',20000), 'b'),
(3, REPEAT('c',40000), 'c'),
(4, REPEAT('d',60000), 'd');
SELECT CHAR_LENGTH(b) FROM t1;
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;
connection default;
SET DEBUG_SYNC='now WAIT_FOR hung';
--source include/restart_mysqld.inc
disconnect hang;
let $shutdown_timeout=60;
CHECK TABLE t1;
SELECT CHAR_LENGTH(b) FROM t1;
DROP TABLE t1;
DROP PROCEDURE populate_t1;