summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThirunarayanan Balathandayuthapani <thiru@mariadb.com>2020-01-28 18:00:19 +0530
committerThirunarayanan Balathandayuthapani <thiru@mariadb.com>2020-01-28 18:21:00 +0530
commita134ec37364bf7f006a73cf8eda212cec6a4f2cc (patch)
tree47aa2e9951615dee136a9de2ae7f693f7bbf6ff5
parentafc16a6faac8c60622ec389dc38b7a223f53a726 (diff)
downloadmariadb-git-a134ec37364bf7f006a73cf8eda212cec6a4f2cc.tar.gz
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.
-rw-r--r--mysql-test/suite/innodb_fts/r/misc_debug.result9
-rw-r--r--mysql-test/suite/innodb_fts/t/misc_debug.test13
-rw-r--r--storage/innobase/fts/fts0opt.cc2
-rw-r--r--storage/innobase/row/row0mysql.cc5
4 files changed, 27 insertions, 2 deletions
diff --git a/mysql-test/suite/innodb_fts/r/misc_debug.result b/mysql-test/suite/innodb_fts/r/misc_debug.result
index 1fcc89b165b..8ef2ac425fc 100644
--- a/mysql-test/suite/innodb_fts/r/misc_debug.result
+++ b/mysql-test/suite/innodb_fts/r/misc_debug.result
@@ -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;
diff --git a/mysql-test/suite/innodb_fts/t/misc_debug.test b/mysql-test/suite/innodb_fts/t/misc_debug.test
index 4b32afb848c..aaf628abe6d 100644
--- a/mysql-test/suite/innodb_fts/t/misc_debug.test
+++ b/mysql-test/suite/innodb_fts/t/misc_debug.test
@@ -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;
diff --git a/storage/innobase/fts/fts0opt.cc b/storage/innobase/fts/fts0opt.cc
index 202bd80d20a..deda14fee24 100644
--- a/storage/innobase/fts/fts0opt.cc
+++ b/storage/innobase/fts/fts0opt.cc
@@ -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);
}
diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc
index 708d2724595..0aa05a702f3 100644
--- a/storage/innobase/row/row0mysql.cc
+++ b/storage/innobase/row/row0mysql.cc
@@ -3806,6 +3806,11 @@ funct_exit:
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);
}