mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
MDEV-18272: Add the test case
The test case was accidentally omitted from the merge
commit 913e33e423
.
This commit is contained in:
@ -137,6 +137,8 @@ SELECT unique_constraint_name FROM information_schema.referential_constraints
|
|||||||
WHERE table_name = 't2';
|
WHERE table_name = 't2';
|
||||||
unique_constraint_name
|
unique_constraint_name
|
||||||
PRIMARY
|
PRIMARY
|
||||||
|
SET @saved_frequency = @@GLOBAL.innodb_purge_rseg_truncate_frequency;
|
||||||
|
SET GLOBAL innodb_purge_rseg_truncate_frequency = 1;
|
||||||
SELECT unique_constraint_name FROM information_schema.referential_constraints
|
SELECT unique_constraint_name FROM information_schema.referential_constraints
|
||||||
WHERE table_name = 't2';
|
WHERE table_name = 't2';
|
||||||
unique_constraint_name
|
unique_constraint_name
|
||||||
@ -194,17 +196,19 @@ DROP DATABASE best;
|
|||||||
#
|
#
|
||||||
# MDEV-17541 KILL QUERY during lock wait in FOREIGN KEY check hangs
|
# MDEV-17541 KILL QUERY during lock wait in FOREIGN KEY check hangs
|
||||||
#
|
#
|
||||||
connect fk, localhost, root,,;
|
connect con1, localhost, root,,;
|
||||||
INSERT INTO t1 SET a=1;
|
INSERT INTO t1 SET a=1;
|
||||||
BEGIN;
|
BEGIN;
|
||||||
DELETE FROM t1;
|
DELETE FROM t1;
|
||||||
connection default;
|
connection default;
|
||||||
INSERT INTO t3 SET a=1;
|
INSERT INTO t3 SET a=1;
|
||||||
connection fk;
|
connection con1;
|
||||||
kill query @id;
|
kill query @id;
|
||||||
connection default;
|
connection default;
|
||||||
ERROR 70100: Query execution was interrupted
|
ERROR 70100: Query execution was interrupted
|
||||||
disconnect fk;
|
connection con1;
|
||||||
|
ROLLBACK;
|
||||||
|
connection default;
|
||||||
DROP TABLE t3,t1;
|
DROP TABLE t3,t1;
|
||||||
#
|
#
|
||||||
# MDEV-18222 InnoDB: Failing assertion: heap->magic_n == MEM_BLOCK_MAGIC_N
|
# MDEV-18222 InnoDB: Failing assertion: heap->magic_n == MEM_BLOCK_MAGIC_N
|
||||||
@ -299,7 +303,7 @@ INSERT INTO matchmaking_group_users VALUES (10,1),(11,2);
|
|||||||
INSERT INTO matchmaking_group_maps VALUES (10,55),(11,66);
|
INSERT INTO matchmaking_group_maps VALUES (10,55),(11,66);
|
||||||
BEGIN;
|
BEGIN;
|
||||||
UPDATE users SET name = 'qux' WHERE id = 1;
|
UPDATE users SET name = 'qux' WHERE id = 1;
|
||||||
connect con1,localhost,root,,;
|
connection con1;
|
||||||
SET innodb_lock_wait_timeout= 1;
|
SET innodb_lock_wait_timeout= 1;
|
||||||
DELETE FROM matchmaking_groups WHERE id = 10;
|
DELETE FROM matchmaking_groups WHERE id = 10;
|
||||||
connection default;
|
connection default;
|
||||||
@ -444,6 +448,69 @@ connection con1;
|
|||||||
kill query @id;
|
kill query @id;
|
||||||
connection default;
|
connection default;
|
||||||
ERROR 70100: Query execution was interrupted
|
ERROR 70100: Query execution was interrupted
|
||||||
disconnect con1;
|
connection con1;
|
||||||
|
ROLLBACK;
|
||||||
|
connection default;
|
||||||
DROP TABLE t2,t1;
|
DROP TABLE t2,t1;
|
||||||
|
#
|
||||||
|
# MDEV-18272 InnoDB index corruption after failed DELETE CASCADE
|
||||||
|
#
|
||||||
|
CREATE TABLE t1 (
|
||||||
|
pk TINYINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
a TINYINT UNSIGNED NOT NULL, b TINYINT UNSIGNED NOT NULL, KEY(b),
|
||||||
|
CONSTRAINT FOREIGN KEY (a) REFERENCES t1 (b) ON DELETE CASCADE
|
||||||
|
) ENGINE=InnoDB;
|
||||||
|
INSERT INTO t1 (a,b) VALUES
|
||||||
|
(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
|
||||||
|
(0,1),(0,1),(1,0);
|
||||||
|
connection con1;
|
||||||
|
START TRANSACTION WITH CONSISTENT SNAPSHOT;
|
||||||
|
connection default;
|
||||||
|
DELETE IGNORE FROM t1 WHERE b = 1;
|
||||||
|
Warnings:
|
||||||
|
Warning 152 InnoDB: Cannot delete/update rows with cascading foreign key constraints that exceed max depth of 20. Please drop extra constraints and try again
|
||||||
|
Warning 1296 Got error 193 '`test`.`t1`, CONSTRAINT `t1_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t1` (`b`) ON DELETE CASCADE' from InnoDB
|
||||||
|
Warning 152 InnoDB: Cannot delete/update rows with cascading foreign key constraints that exceed max depth of 20. Please drop extra constraints and try again
|
||||||
|
Warning 1296 Got error 193 '`test`.`t1`, CONSTRAINT `t1_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t1` (`b`) ON DELETE CASCADE' from InnoDB
|
||||||
|
SELECT a FROM t1 FORCE INDEX(a);
|
||||||
|
a
|
||||||
|
0
|
||||||
|
0
|
||||||
|
0
|
||||||
|
0
|
||||||
|
0
|
||||||
|
0
|
||||||
|
0
|
||||||
|
0
|
||||||
|
0
|
||||||
|
0
|
||||||
|
0
|
||||||
|
0
|
||||||
|
0
|
||||||
|
0
|
||||||
|
1
|
||||||
|
SELECT * FROM t1;
|
||||||
|
pk a b
|
||||||
|
1 0 0
|
||||||
|
2 0 0
|
||||||
|
3 0 0
|
||||||
|
4 0 0
|
||||||
|
5 0 0
|
||||||
|
6 0 0
|
||||||
|
7 0 0
|
||||||
|
8 0 0
|
||||||
|
9 0 0
|
||||||
|
10 0 0
|
||||||
|
11 0 0
|
||||||
|
12 0 0
|
||||||
|
13 0 1
|
||||||
|
14 0 1
|
||||||
|
15 1 0
|
||||||
|
disconnect con1;
|
||||||
|
InnoDB 0 transactions not purged
|
||||||
|
CHECK TABLE t1;
|
||||||
|
Table Op Msg_type Msg_text
|
||||||
|
test.t1 check status OK
|
||||||
|
DROP TABLE t1;
|
||||||
|
SET GLOBAL innodb_purge_rseg_truncate_frequency = @saved_frequency;
|
||||||
# End of 10.2 tests
|
# End of 10.2 tests
|
||||||
|
@ -103,6 +103,9 @@ WHERE table_name = 't2';
|
|||||||
|
|
||||||
--source include/restart_mysqld.inc
|
--source include/restart_mysqld.inc
|
||||||
|
|
||||||
|
SET @saved_frequency = @@GLOBAL.innodb_purge_rseg_truncate_frequency;
|
||||||
|
SET GLOBAL innodb_purge_rseg_truncate_frequency = 1;
|
||||||
|
|
||||||
SELECT unique_constraint_name FROM information_schema.referential_constraints
|
SELECT unique_constraint_name FROM information_schema.referential_constraints
|
||||||
WHERE table_name = 't2';
|
WHERE table_name = 't2';
|
||||||
|
|
||||||
@ -148,6 +151,7 @@ SET FOREIGN_KEY_CHECKS=1;
|
|||||||
call mtr.add_suppression("InnoDB: Possible reasons:");
|
call mtr.add_suppression("InnoDB: Possible reasons:");
|
||||||
call mtr.add_suppression("InnoDB: \\([12]\\) Table ");
|
call mtr.add_suppression("InnoDB: \\([12]\\) Table ");
|
||||||
call mtr.add_suppression("InnoDB: If table `test`\\.`t2` is a temporary table");
|
call mtr.add_suppression("InnoDB: If table `test`\\.`t2` is a temporary table");
|
||||||
|
call mtr.add_suppression("InnoDB: Cannot delete/update rows with cascading foreign key constraints that exceed max depth of 15\\.");
|
||||||
--enable_query_log
|
--enable_query_log
|
||||||
|
|
||||||
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
|
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
|
||||||
@ -165,7 +169,7 @@ DROP DATABASE best;
|
|||||||
--echo #
|
--echo #
|
||||||
--echo # MDEV-17541 KILL QUERY during lock wait in FOREIGN KEY check hangs
|
--echo # MDEV-17541 KILL QUERY during lock wait in FOREIGN KEY check hangs
|
||||||
--echo #
|
--echo #
|
||||||
connect (fk, localhost, root,,);
|
connect (con1, localhost, root,,);
|
||||||
INSERT INTO t1 SET a=1;
|
INSERT INTO t1 SET a=1;
|
||||||
BEGIN;
|
BEGIN;
|
||||||
DELETE FROM t1;
|
DELETE FROM t1;
|
||||||
@ -174,7 +178,7 @@ connection default;
|
|||||||
let $ID= `SELECT @id := CONNECTION_ID()`;
|
let $ID= `SELECT @id := CONNECTION_ID()`;
|
||||||
send INSERT INTO t3 SET a=1;
|
send INSERT INTO t3 SET a=1;
|
||||||
|
|
||||||
connection fk;
|
connection con1;
|
||||||
# Check that the above SELECT is blocked
|
# Check that the above SELECT is blocked
|
||||||
let $wait_condition=
|
let $wait_condition=
|
||||||
select count(*) = 1 from information_schema.processlist
|
select count(*) = 1 from information_schema.processlist
|
||||||
@ -186,7 +190,10 @@ kill query @id;
|
|||||||
connection default;
|
connection default;
|
||||||
--error ER_QUERY_INTERRUPTED
|
--error ER_QUERY_INTERRUPTED
|
||||||
reap;
|
reap;
|
||||||
disconnect fk;
|
|
||||||
|
connection con1;
|
||||||
|
ROLLBACK;
|
||||||
|
connection default;
|
||||||
|
|
||||||
DROP TABLE t3,t1;
|
DROP TABLE t3,t1;
|
||||||
|
|
||||||
@ -286,7 +293,7 @@ INSERT INTO matchmaking_group_maps VALUES (10,55),(11,66);
|
|||||||
BEGIN;
|
BEGIN;
|
||||||
UPDATE users SET name = 'qux' WHERE id = 1;
|
UPDATE users SET name = 'qux' WHERE id = 1;
|
||||||
|
|
||||||
--connect (con1,localhost,root,,)
|
--connection con1
|
||||||
SET innodb_lock_wait_timeout= 1;
|
SET innodb_lock_wait_timeout= 1;
|
||||||
DELETE FROM matchmaking_groups WHERE id = 10;
|
DELETE FROM matchmaking_groups WHERE id = 10;
|
||||||
|
|
||||||
@ -442,10 +449,44 @@ kill query @id;
|
|||||||
connection default;
|
connection default;
|
||||||
--error ER_QUERY_INTERRUPTED
|
--error ER_QUERY_INTERRUPTED
|
||||||
reap;
|
reap;
|
||||||
disconnect con1;
|
|
||||||
|
connection con1;
|
||||||
|
ROLLBACK;
|
||||||
|
connection default;
|
||||||
|
|
||||||
DROP TABLE t2,t1;
|
DROP TABLE t2,t1;
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # MDEV-18272 InnoDB index corruption after failed DELETE CASCADE
|
||||||
|
--echo #
|
||||||
|
CREATE TABLE t1 (
|
||||||
|
pk TINYINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
a TINYINT UNSIGNED NOT NULL, b TINYINT UNSIGNED NOT NULL, KEY(b),
|
||||||
|
CONSTRAINT FOREIGN KEY (a) REFERENCES t1 (b) ON DELETE CASCADE
|
||||||
|
) ENGINE=InnoDB;
|
||||||
|
|
||||||
|
INSERT INTO t1 (a,b) VALUES
|
||||||
|
(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
|
||||||
|
(0,1),(0,1),(1,0);
|
||||||
|
connection con1;
|
||||||
|
START TRANSACTION WITH CONSISTENT SNAPSHOT;
|
||||||
|
|
||||||
|
connection default;
|
||||||
|
DELETE IGNORE FROM t1 WHERE b = 1;
|
||||||
|
|
||||||
|
SELECT a FROM t1 FORCE INDEX(a);
|
||||||
|
# This would wrongly return the empty result if
|
||||||
|
# the "goto rollback_to_savept" in row_mysql_handle_errors() is reverted.
|
||||||
|
SELECT * FROM t1;
|
||||||
|
# Allow purge to continue by closing the read view.
|
||||||
|
disconnect con1;
|
||||||
|
|
||||||
|
# Wait for purge. With the fix reverted, the server would crash here.
|
||||||
|
--source include/wait_all_purged.inc
|
||||||
|
CHECK TABLE t1;
|
||||||
|
DROP TABLE t1;
|
||||||
|
SET GLOBAL innodb_purge_rseg_truncate_frequency = @saved_frequency;
|
||||||
|
|
||||||
--echo # End of 10.2 tests
|
--echo # End of 10.2 tests
|
||||||
|
|
||||||
--source include/wait_until_count_sessions.inc
|
--source include/wait_until_count_sessions.inc
|
||||||
|
Reference in New Issue
Block a user