summaryrefslogtreecommitdiff
path: root/mysql-test/t/myisam.test
diff options
context:
space:
mode:
authorSatya B <satya.bn@sun.com>2009-04-16 17:02:56 +0530
committerSatya B <satya.bn@sun.com>2009-04-16 17:02:56 +0530
commitf6c28cd948a99dbb1cd32eb3b90d8095c957b18c (patch)
treebc548972bb571ab5100e65c78bfbf966fbabb034 /mysql-test/t/myisam.test
parentfc35ded3f4dc639c90a775abc9f7592954662014 (diff)
downloadmariadb-git-f6c28cd948a99dbb1cd32eb3b90d8095c957b18c.tar.gz
BUG#40827 - Killing insert-select to MyISAM can cause table corruption
Killing insert-select statement on MyISAM corrupts the table. Killing the insert-select statement corrupts the MyISAM table only when the destination table is empty and when it has indexes. When we bulk insert huge data and if the destination table is empty we disable the indexes for fast inserts, data is then inserted and indexes are re-enabled after bulk_insert operation Killing the query, aborts the repair table operation during enable indexes phase leading to table corruption. We now truncate the table when we detect that enable indexes is killed for bulk insert query.As we have an empty table before the operation, we can fix by truncating the table.
Diffstat (limited to 'mysql-test/t/myisam.test')
-rw-r--r--mysql-test/t/myisam.test52
1 files changed, 52 insertions, 0 deletions
diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test
index 6d7e03b1c28..14282a366c7 100644
--- a/mysql-test/t/myisam.test
+++ b/mysql-test/t/myisam.test
@@ -1478,5 +1478,57 @@ let $MYSQLD_DATADIR= `select @@datadir`;
--exec $MYISAMCHK -d $MYSQLD_DATADIR/test/t1
DROP TABLE t1;
+--echo #
+--echo # BUG#40827 - Killing insert-select to MyISAM can cause table corruption
+--echo #
+
+CONNECT (insertConn, localhost, root,,);
+
+CREATE TABLE `t1` (
+`id` BIGINT(20) ,
+`id1` BIGINT(20) AUTO_INCREMENT,
+ KEY(id1), KEY(id)
+) ENGINE=MyISAM;
+
+CREATE TABLE `t2` (
+`id` BIGINT(20) ,
+`id1` BIGINT(20) AUTO_INCREMENT,
+ KEY (id1), KEY(id)
+) ENGINE=MyISAM;
+
+INSERT INTO t2 (id) VALUES (123);
+
+let $i = 10;
+while ($i)
+{
+ INSERT INTO t2 (id) SELECT id FROM t2;
+ dec $i;
+}
+
+--echo # Switch to insert Connection
+CONNECTION insertConn;
+SET SESSION debug='+d,wait_in_enable_indexes';
+--echo # Send insert data
+SEND INSERT INTO t1(id) SELECT id FROM t2;
+
+--echo # Switch to default Connection
+CONNECTION default;
+--echo # Wait for insert data to reach the debug point
+
+let $wait_condition=
+ SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST
+ WHERE STATE = "wait_in_enable_indexes" AND
+ INFO = "INSERT INTO t1(id) SELECT id FROM t2";
+--source include/wait_condition.inc
+
+SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST
+WHERE STATE = 'wait_in_enable_indexes' AND
+INFO = "INSERT INTO t1(id) SELECT id FROM t2"
+INTO @thread_id;
+
+KILL QUERY @thread_id;
+CHECK TABLE t1;
+DROP TABLE t1,t2;
+DISCONNECT insertConn;
--echo End of 5.1 tests