mariadb/mysql-test/t/myisam_debug.test
Sergei Golubchik f9264280d6 MDEV-12761 Error return from external_lock make the server crash
bunch of bugs when external_lock() fails on unlock:
* mi_lock_database() used mi_mark_crashed() under share->intern_lock,
  but mi_mark_crashed() itself locks this mutex.
* handler::close() required table to be unlocked, but failed
  external_lock didn't count as unlock
* mysql_unlock_tables() ignored all unlock errors, but they still set
  the error status in stmt_da.
2017-05-15 22:23:10 +02:00

74 lines
1.7 KiB
Text

--source include/have_debug.inc
# We disable this test in embedded mode because of BUG#43733
--source include/not_embedded.inc
--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;
--disable_query_log
begin;
while ($i)
{
INSERT INTO t2 (id) SELECT id FROM t2;
dec $i;
}
commit;
--enable_query_log
--echo # Switch to insert Connection
CONNECTION insertConn;
SET SESSION debug_dbug='+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;
#
# MDEV-12761 Error return from external_lock make the server crash
#
call mtr.add_suppression('Incorrect key file for table');
create table t1 (a int, index(a));
lock tables t1 write;
insert t1 values (1),(2),(1);
set @old_dbug=@@debug_dbug;
set debug_dbug='+d,mi_lock_database_failure';
unlock tables;
set debug_dbug=@old_dbug;
drop table t1;