summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThirunarayanan Balathandayuthapani <thiru@mariadb.com>2021-03-29 18:51:36 +0530
committerThirunarayanan Balathandayuthapani <thiru@mariadb.com>2021-03-30 20:40:14 +0530
commitb771ab242baf238463837b9d19eb59d544bff475 (patch)
tree3d4f771684a29e2357e03737723d96c1778dcb99
parent108ba4c380662bb32555477d7b46b5bdfa54c395 (diff)
downloadmariadb-git-b771ab242baf238463837b9d19eb59d544bff475.tar.gz
MDEV-25200 Index count mismatch due to aborted FULLTEXT INDEX
- Aborting of fulltext index creation fails to remove the index from sys indexes table. When we try to reload the table definition, InnoDB fails with index count mismatch error. InnoDB should remove the index from sys indexes while rollbacking the secondary index creation.
-rw-r--r--mysql-test/suite/innodb_fts/r/misc_debug.result26
-rw-r--r--mysql-test/suite/innodb_fts/t/misc_debug.test31
-rw-r--r--storage/innobase/row/row0merge.cc2
3 files changed, 59 insertions, 0 deletions
diff --git a/mysql-test/suite/innodb_fts/r/misc_debug.result b/mysql-test/suite/innodb_fts/r/misc_debug.result
index 8ef2ac425fc..b162b2f7415 100644
--- a/mysql-test/suite/innodb_fts/r/misc_debug.result
+++ b/mysql-test/suite/innodb_fts/r/misc_debug.result
@@ -26,3 +26,29 @@ SET DEBUG_DBUG="+d,fts_instrument_sync";
INSERT INTO t1 VALUES(1, "mariadb");
ALTER TABLE t1 FORCE;
DROP TABLE t2, t1;
+#
+# MDEV-25200 Index count mismatch due to aborted FULLTEXT INDEX
+#
+CREATE TABLE t1(a INT, b TEXT, c TEXT, FULLTEXT INDEX(b)) ENGINE=InnoDB;
+connect con1,localhost,root,,test;
+SET DEBUG_SYNC='innodb_inplace_alter_table_enter SIGNAL s1 WAIT_FOR g1';
+SET DEBUG_SYNC='innodb_commit_inplace_alter_table_enter SIGNAL s2 WAIT_FOR g2';
+ALTER TABLE t1 ADD FULLTEXT(c);
+connection default;
+SET DEBUG_SYNC='now WAIT_FOR s1';
+KILL QUERY @id;
+SET DEBUG_SYNC='now SIGNAL g1 WAIT_FOR s2';
+START TRANSACTION;
+SELECT * FROM t1;
+a b c
+SET DEBUG_SYNC='now SIGNAL s2';
+connection con1;
+ERROR 70100: Query execution was interrupted
+disconnect con1;
+connection default;
+SET DEBUG_SYNC=RESET;
+ALTER TABLE t1 ADD bl INT AS (LENGTH(b)) VIRTUAL;
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+DROP TABLE t1;
diff --git a/mysql-test/suite/innodb_fts/t/misc_debug.test b/mysql-test/suite/innodb_fts/t/misc_debug.test
index aaf628abe6d..461e3f1d9d4 100644
--- a/mysql-test/suite/innodb_fts/t/misc_debug.test
+++ b/mysql-test/suite/innodb_fts/t/misc_debug.test
@@ -5,6 +5,8 @@
--source include/have_innodb.inc
--source include/have_debug.inc
+--source include/have_debug_sync.inc
+--source include/count_sessions.inc
# Following test is for Bug 14668777 - ASSERT ON IB_VECTOR_SIZE(
# TABLE->FTS->INDEXES, ALTER TABLE
@@ -52,3 +54,32 @@ INSERT INTO t1 VALUES(1, "mariadb");
ALTER TABLE t1 FORCE;
# Cleanup
DROP TABLE t2, t1;
+
+--echo #
+--echo # MDEV-25200 Index count mismatch due to aborted FULLTEXT INDEX
+--echo #
+CREATE TABLE t1(a INT, b TEXT, c TEXT, FULLTEXT INDEX(b)) ENGINE=InnoDB;
+connect(con1,localhost,root,,test);
+let $ID= `SELECT @id := CONNECTION_ID()`;
+SET DEBUG_SYNC='innodb_inplace_alter_table_enter SIGNAL s1 WAIT_FOR g1';
+SET DEBUG_SYNC='innodb_commit_inplace_alter_table_enter SIGNAL s2 WAIT_FOR g2';
+send ALTER TABLE t1 ADD FULLTEXT(c);
+connection default;
+SET DEBUG_SYNC='now WAIT_FOR s1';
+let $ignore= `SELECT @id := $ID`;
+KILL QUERY @id;
+SET DEBUG_SYNC='now SIGNAL g1 WAIT_FOR s2';
+START TRANSACTION;
+SELECT * FROM t1;
+SET DEBUG_SYNC='now SIGNAL s2';
+connection con1;
+--error ER_QUERY_INTERRUPTED
+reap;
+disconnect con1;
+connection default;
+SET DEBUG_SYNC=RESET;
+# Exploit MDEV-17468 to force the table definition to be reloaded
+ALTER TABLE t1 ADD bl INT AS (LENGTH(b)) VIRTUAL;
+CHECK TABLE t1;
+DROP TABLE t1;
+--source include/wait_until_count_sessions.inc
diff --git a/storage/innobase/row/row0merge.cc b/storage/innobase/row/row0merge.cc
index 3de85f024a3..835d74043fd 100644
--- a/storage/innobase/row/row0merge.cc
+++ b/storage/innobase/row/row0merge.cc
@@ -3768,6 +3768,8 @@ row_merge_drop_indexes(
ut_ad(prev);
ut_a(table->fts);
fts_drop_index(table, index, trx);
+ row_merge_drop_index_dict(
+ trx, index->id);
/* We can remove a DICT_FTS
index from the cache, because
we do not allow ADD FULLTEXT INDEX