summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnnamalai Gurusami <annamalai.gurusami@oracle.com>2015-04-20 14:45:47 +0530
committerThirunarayanan Balathandayuthapani <thiru@mariadb.com>2018-05-16 15:03:09 +0530
commita1f392a9445b57951db47f12bd5c42251c64ba41 (patch)
treeeb714cfd17949971e8e1f9839e95c472c297187f
parent91659983eb70be6d4169c21c11f47586bf66826d (diff)
downloadmariadb-git-a1f392a9445b57951db47f12bd5c42251c64ba41.tar.gz
Bug #20476395 DICT_LOAD_FOREIGNS() FAILED IN COMMIT_INPLACE_ALTER_TABLE
Problem: Suppose there are two tables in the database related through a foreign key constraint - the parent table and the child table. Suppose there is an ALTER TABLE on the child table which gets interrupted in such a way that the child table is not available any more. After crash recovery, an ALTER TABLE on the parent table identifies that its foreign keys cannot be loaded. This results in an error and a debug assert. Solution: Remove the debug assert and change error to a warning. rb#8658 approved by Marko.
-rw-r--r--mysql-test/suite/innodb/r/alter_foreign_crash.result25
-rw-r--r--mysql-test/suite/innodb/t/alter_foreign_crash.test37
2 files changed, 62 insertions, 0 deletions
diff --git a/mysql-test/suite/innodb/r/alter_foreign_crash.result b/mysql-test/suite/innodb/r/alter_foreign_crash.result
new file mode 100644
index 00000000000..a92c8246fde
--- /dev/null
+++ b/mysql-test/suite/innodb/r/alter_foreign_crash.result
@@ -0,0 +1,25 @@
+#
+# Bug #20476395 DICT_LOAD_FOREIGNS() FAILED IN
+# COMMIT_INPLACE_ALTER_TABLE
+#
+call mtr.add_suppression("InnoDB: Failed to load table");
+create database bug;
+use bug;
+create table parent(a serial) engine=innodb;
+create table child(a serial, foreign key fk (a) references parent(a));
+insert into parent values(1);
+insert into child values(1);
+SET DEBUG_SYNC='innodb_rename_table_ready SIGNAL s1 WAIT_FOR s2 EXECUTE 2';
+ALTER TABLE child ROW_FORMAT=DYNAMIC, ALGORITHM=COPY;
+SET DEBUG_SYNC='now WAIT_FOR s1';
+SET DEBUG_SYNC='now SIGNAL s2 WAIT_FOR s1';
+# Kill and restart
+show tables;
+Tables_in_bug
+parent
+alter table parent row_format=dynamic;
+Warnings:
+Warning 1088 InnoDB: Could not add foreign key constraints.
+drop table parent;
+ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails
+drop database bug;
diff --git a/mysql-test/suite/innodb/t/alter_foreign_crash.test b/mysql-test/suite/innodb/t/alter_foreign_crash.test
new file mode 100644
index 00000000000..042fa1dc0ae
--- /dev/null
+++ b/mysql-test/suite/innodb/t/alter_foreign_crash.test
@@ -0,0 +1,37 @@
+--source include/have_innodb.inc
+--source include/have_debug_sync.inc
+# The embedded server does not support restarting.
+--source include/not_embedded.inc
+
+--echo #
+--echo # Bug #20476395 DICT_LOAD_FOREIGNS() FAILED IN
+--echo # COMMIT_INPLACE_ALTER_TABLE
+--echo #
+
+call mtr.add_suppression("InnoDB: Failed to load table");
+
+create database bug;
+use bug;
+
+create table parent(a serial) engine=innodb;
+create table child(a serial, foreign key fk (a) references parent(a));
+
+insert into parent values(1);
+insert into child values(1);
+
+connect (con1,localhost,root,,bug);
+SET DEBUG_SYNC='innodb_rename_table_ready SIGNAL s1 WAIT_FOR s2 EXECUTE 2';
+--send ALTER TABLE child ROW_FORMAT=DYNAMIC, ALGORITHM=COPY
+connection default;
+SET DEBUG_SYNC='now WAIT_FOR s1';
+SET DEBUG_SYNC='now SIGNAL s2 WAIT_FOR s1';
+--source include/kill_and_restart_mysqld.inc
+disconnect con1;
+
+show tables;
+alter table parent row_format=dynamic;
+
+--error ER_ROW_IS_REFERENCED
+drop table parent;
+
+drop database bug;