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.
parent afc16a6f
......@@ -17,3 +17,12 @@ ALTER TABLE t ADD FULLTEXT INDEX (b(64));
ERROR HY000: Unknown error
SET SESSION debug_dbug=@saved_debug_dbug;
DROP TABLE t;
CREATE TABLE t1 (pk INT, a VARCHAR(8), PRIMARY KEY(pk),
FULLTEXT KEY(a)) ENGINE=InnoDB;
CREATE TABLE t2 (b INT, FOREIGN KEY(b) REFERENCES t1(pk)) ENGINE=InnoDB;
DROP TABLE t1;
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails
SET DEBUG_DBUG="+d,fts_instrument_sync";
INSERT INTO t1 VALUES(1, "mariadb");
ALTER TABLE t1 FORCE;
DROP TABLE t2, t1;
......@@ -39,3 +39,16 @@ ALTER TABLE t ADD FULLTEXT INDEX (b(64));
SET SESSION debug_dbug=@saved_debug_dbug;
DROP TABLE t;
# MDEV-21550 Assertion `!table->fts->in_queue' failed in
# fts_optimize_remove_table
CREATE TABLE t1 (pk INT, a VARCHAR(8), PRIMARY KEY(pk),
FULLTEXT KEY(a)) ENGINE=InnoDB;
CREATE TABLE t2 (b INT, FOREIGN KEY(b) REFERENCES t1(pk)) ENGINE=InnoDB;
--error ER_ROW_IS_REFERENCED_2
DROP TABLE t1;
SET DEBUG_DBUG="+d,fts_instrument_sync";
INSERT INTO t1 VALUES(1, "mariadb");
ALTER TABLE t1 FORCE;
# Cleanup
DROP TABLE t2, t1;
......@@ -2645,8 +2645,6 @@ fts_optimize_request_sync_table(
ib_wqueue_add(fts_optimize_wq, msg, msg->heap, true);
table->fts->in_queue = true;
mutex_exit(&fts_optimize_wq->mutex);
}
......
......@@ -3806,6 +3806,11 @@ row_drop_table_for_mysql(
trx_commit_for_mysql(trx);
}
/* Add the table to fts queue if drop table fails */
if (err != DB_SUCCESS && table->fts) {
fts_optimize_add_table(table);
}
row_mysql_unlock_data_dictionary(trx);
}
......
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