TOI during FK update fails: Error on rename of .. Table is being used in foreign key check
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
MySQL patches by Codership |
New
|
Undecided
|
Unassigned |
Bug Description
The test below performs ALTER ADD FOREIGN KEY while a concurrent UPDATE is running. TOI then fails on the node running the UPDATE:
2014-10-16 11:58:10 7fbd596be700 InnoDB: Error: in ALTER TABLE `test`.
InnoDB: a FOREIGN KEY check is running.
InnoDB: Cannot rename table.
2014-10-16 11:58:10 7fbd596be700 InnoDB: You are trying to drop table `test`.
InnoDB: though there is a foreign key check running on it.
InnoDB: Adding the table to the background drop queue.
2014-10-16 11:58:10 6809 [ERROR] Slave SQL: Error 'Error on rename of './test/
2014-10-16 11:58:10 6809 [Warning] WSREP: RBR event 1 Query apply warning: 1, 7
2014-10-16 11:58:10 6809 [Warning] WSREP: Ignoring error for TO isolated action: source: 735e0b4e-
2014-10-16 11:58:39 7fbd3bdf2700 InnoDB: Dropped table "test".
Test :
--source include/
--source include/
--source include/
#
# This test creates a new FK constraint while an UPDATE is running
#
CREATE TABLE ten (f1 INTEGER) ENGINE=InnoDB;
INSERT INTO ten VALUES (1),(2)
CREATE TABLE parent (
id INT PRIMARY KEY,
KEY (id)
) ENGINE=InnoDB;
CREATE TABLE child (
id INT PRIMARY KEY AUTO_INCREMENT,
parent_id INT
) ENGINE=InnoDB;
INSERT INTO parent VALUES (1);
INSERT INTO child (parent_id) SELECT 1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5;
--connection node_1
--sleep 1
--send ALTER TABLE child ADD FOREIGN KEY (parent_id) REFERENCES parent(id) ON UPDATE CASCADE;
--connection node_2
--send UPDATE parent SET id = 2 WHERE id = 1;
--connection node_1
--reap
--connection node_2
--reap
--connection node_2
SELECT COUNT(*) = 100000 FROM child WHERE parent_id = 2;
--connection node_1
SELECT COUNT(*) = 100000 FROM child WHERE parent_id = 2;
DROP TABLE child;
DROP TABLE parent;
DROP TABLE ten;