Skip to content

Commit

Permalink
MDEV-19647 Server hangs after dropping full text indexes and restart
Browse files Browse the repository at this point in the history
- There is no need to add the table in fts_optimize_wq if there is
no fts indexes associated with it.
  • Loading branch information
Thirunarayanan committed Sep 17, 2019
1 parent ae2b88f commit 708f1e3
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 6 deletions.
14 changes: 10 additions & 4 deletions mysql-test/suite/innodb_fts/r/innodb_fts_misc.result
Original file line number Diff line number Diff line change
Expand Up @@ -734,15 +734,21 @@ count(*)
DROP TABLE t1;
"----------Test27---------"
CREATE TABLE t1 (id INT,char_column VARCHAR(60));
CREATE TABLE t2 (FTS_DOC_ID BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, a TEXT)ENGINE=InnoDB;
ALTER TABLE t2 DROP a;
SET @@autocommit=0;
CREATE FULLTEXT INDEX i ON t1 (char_column);
INSERT INTO t1 values (1,'aaa');
"restart server..."
# Restart the server
--source include/restart_mysqld.inc
DELETE FROM t1 WHERE MATCH(char_column) AGAINST ('bbb')
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`FTS_DOC_ID` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`FTS_DOC_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
DELETE FROM t1 WHERE MATCH(char_column) AGAINST ('bbb');
SET @@autocommit=1;
DROP TABLE t1;
DROP TABLE t1, t2;
"----------Test28---------"
drop table if exists `fts_test`;
Warnings:
Expand Down
7 changes: 5 additions & 2 deletions mysql-test/suite/innodb_fts/t/innodb_fts_misc.test
Original file line number Diff line number Diff line change
Expand Up @@ -667,15 +667,18 @@ DROP TABLE t1;
--echo "----------Test27---------"
#27 Crash after server restart
CREATE TABLE t1 (id INT,char_column VARCHAR(60));
CREATE TABLE t2 (FTS_DOC_ID BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, a TEXT)ENGINE=InnoDB;
ALTER TABLE t2 DROP a;
SET @@autocommit=0;
CREATE FULLTEXT INDEX i ON t1 (char_column);
INSERT INTO t1 values (1,'aaa');
echo "restart server..."
echo "restart server...";
# Restart the server
--source include/restart_mysqld.inc
SHOW CREATE TABLE t2;
DELETE FROM t1 WHERE MATCH(char_column) AGAINST ('bbb');
SET @@autocommit=1;
DROP TABLE t1;
DROP TABLE t1, t2;

--echo "----------Test28---------"
drop table if exists `fts_test`;
Expand Down
6 changes: 6 additions & 0 deletions storage/innobase/fts/fts0opt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2614,6 +2614,12 @@ UNIV_INTERN void fts_optimize_add_table(dict_table_t* table)
return;
}

/* If there is no fts index present then don't add to
optimize queue. */
if (!ib_vector_size(table->fts->indexes)) {
return;
}

/* Make sure table with FTS index cannot be evicted */
if (table->can_be_evicted) {
dict_table_move_from_lru_to_non_lru(table);
Expand Down
6 changes: 6 additions & 0 deletions storage/xtradb/fts/fts0opt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2614,6 +2614,12 @@ UNIV_INTERN void fts_optimize_add_table(dict_table_t* table)
return;
}

/* If there is no fts index present then don't add to
optimize queue. */
if (!ib_vector_size(table->fts->indexes)) {
return;
}

/* Make sure table with FTS index cannot be evicted */
if (table->can_be_evicted) {
dict_table_move_from_lru_to_non_lru(table);
Expand Down

0 comments on commit 708f1e3

Please sign in to comment.