Commit a1f392a9 authored by Annamalai Gurusami's avatar Annamalai Gurusami Committed by Thirunarayanan Balathandayuthapani

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.
parent 91659983
#
# 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;
--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;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment