Skip to content

Commit 708f1e3

Browse files
MDEV-19647 Server hangs after dropping full text indexes and restart
- There is no need to add the table in fts_optimize_wq if there is no fts indexes associated with it.
1 parent ae2b88f commit 708f1e3

File tree

4 files changed

+27
-6
lines changed

4 files changed

+27
-6
lines changed

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -734,15 +734,21 @@ count(*)
734734
DROP TABLE t1;
735735
"----------Test27---------"
736736
CREATE TABLE t1 (id INT,char_column VARCHAR(60));
737+
CREATE TABLE t2 (FTS_DOC_ID BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, a TEXT)ENGINE=InnoDB;
738+
ALTER TABLE t2 DROP a;
737739
SET @@autocommit=0;
738740
CREATE FULLTEXT INDEX i ON t1 (char_column);
739741
INSERT INTO t1 values (1,'aaa');
740742
"restart server..."
741-
# Restart the server
742-
--source include/restart_mysqld.inc
743-
DELETE FROM t1 WHERE MATCH(char_column) AGAINST ('bbb')
743+
SHOW CREATE TABLE t2;
744+
Table Create Table
745+
t2 CREATE TABLE `t2` (
746+
`FTS_DOC_ID` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
747+
PRIMARY KEY (`FTS_DOC_ID`)
748+
) ENGINE=InnoDB DEFAULT CHARSET=latin1
749+
DELETE FROM t1 WHERE MATCH(char_column) AGAINST ('bbb');
744750
SET @@autocommit=1;
745-
DROP TABLE t1;
751+
DROP TABLE t1, t2;
746752
"----------Test28---------"
747753
drop table if exists `fts_test`;
748754
Warnings:

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -667,15 +667,18 @@ DROP TABLE t1;
667667
--echo "----------Test27---------"
668668
#27 Crash after server restart
669669
CREATE TABLE t1 (id INT,char_column VARCHAR(60));
670+
CREATE TABLE t2 (FTS_DOC_ID BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, a TEXT)ENGINE=InnoDB;
671+
ALTER TABLE t2 DROP a;
670672
SET @@autocommit=0;
671673
CREATE FULLTEXT INDEX i ON t1 (char_column);
672674
INSERT INTO t1 values (1,'aaa');
673-
echo "restart server..."
675+
echo "restart server...";
674676
# Restart the server
675677
--source include/restart_mysqld.inc
678+
SHOW CREATE TABLE t2;
676679
DELETE FROM t1 WHERE MATCH(char_column) AGAINST ('bbb');
677680
SET @@autocommit=1;
678-
DROP TABLE t1;
681+
DROP TABLE t1, t2;
679682

680683
--echo "----------Test28---------"
681684
drop table if exists `fts_test`;

storage/innobase/fts/fts0opt.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2614,6 +2614,12 @@ UNIV_INTERN void fts_optimize_add_table(dict_table_t* table)
26142614
return;
26152615
}
26162616

2617+
/* If there is no fts index present then don't add to
2618+
optimize queue. */
2619+
if (!ib_vector_size(table->fts->indexes)) {
2620+
return;
2621+
}
2622+
26172623
/* Make sure table with FTS index cannot be evicted */
26182624
if (table->can_be_evicted) {
26192625
dict_table_move_from_lru_to_non_lru(table);

storage/xtradb/fts/fts0opt.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2614,6 +2614,12 @@ UNIV_INTERN void fts_optimize_add_table(dict_table_t* table)
26142614
return;
26152615
}
26162616

2617+
/* If there is no fts index present then don't add to
2618+
optimize queue. */
2619+
if (!ib_vector_size(table->fts->indexes)) {
2620+
return;
2621+
}
2622+
26172623
/* Make sure table with FTS index cannot be evicted */
26182624
if (table->can_be_evicted) {
26192625
dict_table_move_from_lru_to_non_lru(table);

0 commit comments

Comments
 (0)