Skip to content

Commit c903ba2

Browse files
committed
MDEV-13205 InnoDB: Failing assertion: !dict_index_is_online_ddl(index) upon ALTER TABLE
dict_foreign_find_index(): Ignore incompletely created indexes. After a failed ADD UNIQUE INDEX, an incompletely created index could be left behind until the next ALTER TABLE statement.
1 parent 4496fd7 commit c903ba2

File tree

4 files changed

+43
-2
lines changed

4 files changed

+43
-2
lines changed

mysql-test/suite/innodb/r/innodb-index-online.result

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,22 @@ ERROR 42000: Duplicate key name 'c2h'
339339
SET DEBUG_SYNC = 'RESET';
340340
SET GLOBAL innodb_monitor_disable = module_ddl;
341341
DROP TABLE t1;
342+
#
343+
# MDEV-13205 assertion !dict_index_is_online_ddl(index) upon ALTER TABLE
344+
#
345+
CREATE TABLE t1 (c VARCHAR(64)) ENGINE=InnoDB;
346+
SET DEBUG_SYNC = 'row_log_apply_before SIGNAL t1u_created WAIT_FOR dup_done';
347+
ALTER TABLE t1 ADD UNIQUE(c);
348+
SET DEBUG_SYNC = 'now WAIT_FOR t1u_created';
349+
BEGIN;
350+
INSERT INTO t1 VALUES('bar'),('bar');
351+
SET DEBUG_SYNC = 'now SIGNAL dup_done';
352+
ERROR 23000: Duplicate entry 'bar' for key 'c'
353+
SET DEBUG_SYNC = 'RESET';
354+
CREATE TABLE t2 (c VARCHAR(64)) ENGINE=InnoDB;
355+
ALTER TABLE t2 ADD FOREIGN KEY (c) REFERENCES t1 (c);
356+
ERROR HY000: Can't create table `test`.`#sql-temporary` (errno: 150 "Foreign key constraint is incorrectly formed")
357+
DROP TABLE t2,t1;
342358
SET GLOBAL innodb_file_per_table = @global_innodb_file_per_table_orig;
343359
SET GLOBAL innodb_monitor_enable = default;
344360
SET GLOBAL innodb_monitor_disable = default;

mysql-test/suite/innodb/t/innodb-index-online.test

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,8 +382,6 @@ connection default;
382382
reap;
383383
--enable_parsing
384384
#remove below con1 disconnect if above test case is enabled
385-
connection con1;
386-
disconnect con1;
387385
connection default;
388386

389387
SHOW CREATE TABLE t1;
@@ -399,6 +397,31 @@ SET GLOBAL innodb_monitor_disable = module_ddl;
399397

400398
DROP TABLE t1;
401399

400+
--echo #
401+
--echo # MDEV-13205 assertion !dict_index_is_online_ddl(index) upon ALTER TABLE
402+
--echo #
403+
CREATE TABLE t1 (c VARCHAR(64)) ENGINE=InnoDB;
404+
SET DEBUG_SYNC = 'row_log_apply_before SIGNAL t1u_created WAIT_FOR dup_done';
405+
send ALTER TABLE t1 ADD UNIQUE(c);
406+
407+
connection con1;
408+
SET DEBUG_SYNC = 'now WAIT_FOR t1u_created';
409+
BEGIN;
410+
INSERT INTO t1 VALUES('bar'),('bar');
411+
SET DEBUG_SYNC = 'now SIGNAL dup_done';
412+
413+
connection default;
414+
--error ER_DUP_ENTRY
415+
reap;
416+
417+
SET DEBUG_SYNC = 'RESET';
418+
disconnect con1;
419+
CREATE TABLE t2 (c VARCHAR(64)) ENGINE=InnoDB;
420+
--replace_regex /#sql-[0-9a-f_]*/#sql-temporary/
421+
--error ER_CANT_CREATE_TABLE
422+
ALTER TABLE t2 ADD FOREIGN KEY (c) REFERENCES t1 (c);
423+
DROP TABLE t2,t1;
424+
402425
# Check that all connections opened by test cases in this file are really
403426
# gone so execution of other tests won't be affected by their presence.
404427
--source include/wait_until_count_sessions.inc

storage/innobase/dict/dict0dict.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3364,6 +3364,7 @@ dict_foreign_find_index(
33643364
if (types_idx != index
33653365
&& !(index->type & DICT_FTS)
33663366
&& !index->to_be_dropped
3367+
&& !dict_index_is_online_ddl(index)
33673368
&& dict_foreign_qualify_index(
33683369
table, col_names, columns, n_cols,
33693370
index, types_idx,

storage/xtradb/dict/dict0dict.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3378,6 +3378,7 @@ dict_foreign_find_index(
33783378
if (types_idx != index
33793379
&& !(index->type & DICT_FTS)
33803380
&& !index->to_be_dropped
3381+
&& !dict_index_is_online_ddl(index)
33813382
&& dict_foreign_qualify_index(
33823383
table, col_names, columns, n_cols,
33833384
index, types_idx,

0 commit comments

Comments
 (0)