Skip to content

Commit b771ab2

Browse files
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.
1 parent 108ba4c commit b771ab2

File tree

3 files changed

+59
-0
lines changed

3 files changed

+59
-0
lines changed

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,29 @@ SET DEBUG_DBUG="+d,fts_instrument_sync";
2626
INSERT INTO t1 VALUES(1, "mariadb");
2727
ALTER TABLE t1 FORCE;
2828
DROP TABLE t2, t1;
29+
#
30+
# MDEV-25200 Index count mismatch due to aborted FULLTEXT INDEX
31+
#
32+
CREATE TABLE t1(a INT, b TEXT, c TEXT, FULLTEXT INDEX(b)) ENGINE=InnoDB;
33+
connect con1,localhost,root,,test;
34+
SET DEBUG_SYNC='innodb_inplace_alter_table_enter SIGNAL s1 WAIT_FOR g1';
35+
SET DEBUG_SYNC='innodb_commit_inplace_alter_table_enter SIGNAL s2 WAIT_FOR g2';
36+
ALTER TABLE t1 ADD FULLTEXT(c);
37+
connection default;
38+
SET DEBUG_SYNC='now WAIT_FOR s1';
39+
KILL QUERY @id;
40+
SET DEBUG_SYNC='now SIGNAL g1 WAIT_FOR s2';
41+
START TRANSACTION;
42+
SELECT * FROM t1;
43+
a b c
44+
SET DEBUG_SYNC='now SIGNAL s2';
45+
connection con1;
46+
ERROR 70100: Query execution was interrupted
47+
disconnect con1;
48+
connection default;
49+
SET DEBUG_SYNC=RESET;
50+
ALTER TABLE t1 ADD bl INT AS (LENGTH(b)) VIRTUAL;
51+
CHECK TABLE t1;
52+
Table Op Msg_type Msg_text
53+
test.t1 check status OK
54+
DROP TABLE t1;

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
--source include/have_innodb.inc
77
--source include/have_debug.inc
8+
--source include/have_debug_sync.inc
9+
--source include/count_sessions.inc
810

911
# Following test is for Bug 14668777 - ASSERT ON IB_VECTOR_SIZE(
1012
# TABLE->FTS->INDEXES, ALTER TABLE
@@ -52,3 +54,32 @@ INSERT INTO t1 VALUES(1, "mariadb");
5254
ALTER TABLE t1 FORCE;
5355
# Cleanup
5456
DROP TABLE t2, t1;
57+
58+
--echo #
59+
--echo # MDEV-25200 Index count mismatch due to aborted FULLTEXT INDEX
60+
--echo #
61+
CREATE TABLE t1(a INT, b TEXT, c TEXT, FULLTEXT INDEX(b)) ENGINE=InnoDB;
62+
connect(con1,localhost,root,,test);
63+
let $ID= `SELECT @id := CONNECTION_ID()`;
64+
SET DEBUG_SYNC='innodb_inplace_alter_table_enter SIGNAL s1 WAIT_FOR g1';
65+
SET DEBUG_SYNC='innodb_commit_inplace_alter_table_enter SIGNAL s2 WAIT_FOR g2';
66+
send ALTER TABLE t1 ADD FULLTEXT(c);
67+
connection default;
68+
SET DEBUG_SYNC='now WAIT_FOR s1';
69+
let $ignore= `SELECT @id := $ID`;
70+
KILL QUERY @id;
71+
SET DEBUG_SYNC='now SIGNAL g1 WAIT_FOR s2';
72+
START TRANSACTION;
73+
SELECT * FROM t1;
74+
SET DEBUG_SYNC='now SIGNAL s2';
75+
connection con1;
76+
--error ER_QUERY_INTERRUPTED
77+
reap;
78+
disconnect con1;
79+
connection default;
80+
SET DEBUG_SYNC=RESET;
81+
# Exploit MDEV-17468 to force the table definition to be reloaded
82+
ALTER TABLE t1 ADD bl INT AS (LENGTH(b)) VIRTUAL;
83+
CHECK TABLE t1;
84+
DROP TABLE t1;
85+
--source include/wait_until_count_sessions.inc

storage/innobase/row/row0merge.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3768,6 +3768,8 @@ row_merge_drop_indexes(
37683768
ut_ad(prev);
37693769
ut_a(table->fts);
37703770
fts_drop_index(table, index, trx);
3771+
row_merge_drop_index_dict(
3772+
trx, index->id);
37713773
/* We can remove a DICT_FTS
37723774
index from the cache, because
37733775
we do not allow ADD FULLTEXT INDEX

0 commit comments

Comments
 (0)