Skip to content

Commit a134ec3

Browse files
MDEV-21550 Assertion `!table->fts->in_queue' failed in fts_optimize_remove_table
Problem: ======= The problem is that InnoDB doesn't add the table in fts slots if drop table fails. InnoDB marks the table is in fts slots while processing sync message. So the consecutive alter statement assumes that table is in queue and tries to remove it. But InnoDB can't find the table in fts_slots. Solution: ========= i) Removal of in_queue in fts_t while processing the fts sync message. ii) Add the table to fts_slots when drop table fails.
1 parent afc16a6 commit a134ec3

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed

mysql-test/suite/innodb_fts/r/misc_debug.result

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,12 @@ ALTER TABLE t ADD FULLTEXT INDEX (b(64));
1717
ERROR HY000: Unknown error
1818
SET SESSION debug_dbug=@saved_debug_dbug;
1919
DROP TABLE t;
20+
CREATE TABLE t1 (pk INT, a VARCHAR(8), PRIMARY KEY(pk),
21+
FULLTEXT KEY(a)) ENGINE=InnoDB;
22+
CREATE TABLE t2 (b INT, FOREIGN KEY(b) REFERENCES t1(pk)) ENGINE=InnoDB;
23+
DROP TABLE t1;
24+
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails
25+
SET DEBUG_DBUG="+d,fts_instrument_sync";
26+
INSERT INTO t1 VALUES(1, "mariadb");
27+
ALTER TABLE t1 FORCE;
28+
DROP TABLE t2, t1;

mysql-test/suite/innodb_fts/t/misc_debug.test

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,16 @@ ALTER TABLE t ADD FULLTEXT INDEX (b(64));
3939
SET SESSION debug_dbug=@saved_debug_dbug;
4040

4141
DROP TABLE t;
42+
43+
# MDEV-21550 Assertion `!table->fts->in_queue' failed in
44+
# fts_optimize_remove_table
45+
CREATE TABLE t1 (pk INT, a VARCHAR(8), PRIMARY KEY(pk),
46+
FULLTEXT KEY(a)) ENGINE=InnoDB;
47+
CREATE TABLE t2 (b INT, FOREIGN KEY(b) REFERENCES t1(pk)) ENGINE=InnoDB;
48+
--error ER_ROW_IS_REFERENCED_2
49+
DROP TABLE t1;
50+
SET DEBUG_DBUG="+d,fts_instrument_sync";
51+
INSERT INTO t1 VALUES(1, "mariadb");
52+
ALTER TABLE t1 FORCE;
53+
# Cleanup
54+
DROP TABLE t2, t1;

storage/innobase/fts/fts0opt.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2645,8 +2645,6 @@ fts_optimize_request_sync_table(
26452645

26462646
ib_wqueue_add(fts_optimize_wq, msg, msg->heap, true);
26472647

2648-
table->fts->in_queue = true;
2649-
26502648
mutex_exit(&fts_optimize_wq->mutex);
26512649
}
26522650

storage/innobase/row/row0mysql.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3806,6 +3806,11 @@ row_drop_table_for_mysql(
38063806
trx_commit_for_mysql(trx);
38073807
}
38083808

3809+
/* Add the table to fts queue if drop table fails */
3810+
if (err != DB_SUCCESS && table->fts) {
3811+
fts_optimize_add_table(table);
3812+
}
3813+
38093814
row_mysql_unlock_data_dictionary(trx);
38103815
}
38113816

0 commit comments

Comments
 (0)