mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
MDEV-28317 Assertion failures in row_undo_mod on recovery
Starting with 10.3, an assertion would fail on the rollback of
a recovered incomplete transaction if a table definition violates
a FOREIGN KEY constraint.
DICT_ERR_IGNORE_RECOVER_LOCK: Include also DICT_ERR_IGNORE_FK_NOKEY
so that trx_resurrect_table_locks() will be able to load
table definitions and resurrect IX locks. Previously, if the
FOREIGN KEY constraints of a table were incomplete, the table
would fail to load until rollback, and in 10.3 or later an assertion
would fail that the rollback was not protected by a table IX lock.
Thanks to commit 9de2e60d74
there
will be no problems to enforce subsequent FOREIGN KEY operations
even though a table with invalid REFERENCES clause was loaded.
This commit is contained in:
@@ -137,6 +137,33 @@ SELECT unique_constraint_name FROM information_schema.referential_constraints
|
||||
WHERE table_name = 't2';
|
||||
unique_constraint_name
|
||||
PRIMARY
|
||||
#
|
||||
# MDEV-28317 Assertion failure on rollback of FOREIGN KEY operation
|
||||
#
|
||||
SET foreign_key_checks=0;
|
||||
CREATE TABLE parent(a INT PRIMARY KEY) ENGINE=InnoDB;
|
||||
CREATE TABLE child(a INT,FOREIGN KEY(a) REFERENCES parent(a) ON DELETE CASCADE)
|
||||
ENGINE=InnoDB;
|
||||
INSERT INTO child VALUES(1);
|
||||
ALTER TABLE child DROP INDEX a;
|
||||
connect incomplete, localhost, root,,;
|
||||
BEGIN;
|
||||
DELETE FROM child;
|
||||
connection default;
|
||||
INSERT INTO parent SET a=0;
|
||||
FLUSH TABLES;
|
||||
disconnect incomplete;
|
||||
INSERT INTO child SET a=0;
|
||||
INSERT INTO child SET a=1;
|
||||
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`child`, CONSTRAINT `child_ibfk_1` FOREIGN KEY (`a`) REFERENCES `parent` (`a`) ON DELETE CASCADE)
|
||||
DELETE FROM parent;
|
||||
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`child`, CONSTRAINT `child_ibfk_1` FOREIGN KEY (`a`) REFERENCES `parent` (`a`) ON DELETE CASCADE)
|
||||
ALTER TABLE child ADD INDEX(a);
|
||||
DELETE FROM parent;
|
||||
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`child`, CONSTRAINT `child_ibfk_1` FOREIGN KEY (`a`) REFERENCES `parent` (`a`) ON DELETE CASCADE)
|
||||
ALTER TABLE child FORCE;
|
||||
DELETE FROM parent;
|
||||
DROP TABLE child,parent;
|
||||
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
|
||||
|
Reference in New Issue
Block a user