Skip to content

Commit 3c98704

Browse files
Bug #26334149 - MYSQL CRASHES WHEN FULL TEXT INDEXES IBD FILES
ARE ORPHANED DUE TO RENAME TABLE Problem: When FTS index is added into a table which doesn't have 'FTS_DOC_ID' column, Innodb rebuilds table to add column 'FTS_DOC_ID'. when this FTS index is dropped from this table. Innodb doesn't not rebuild table to remove 'FTS_DOC_ID' column and deletes FTS index auxiliary tables. But it doesn't delete FTS common auxiliary tables. Later when the database having this table is renamed, FTS auxiliary tables are not renamed because table's flags2 (dict_table_t.flags2) has been resetted for DICT_TF2_FTS flag during FTS index drop operation. Now when we drop old database, it leads to an assert. Fix: During renaming of FTS auxiliary tables, ORed a condition to check if table has DICT_TF2_FTS_HAS_DOC_ID flag set. RB: 18769 Reviewed by : [email protected]
1 parent b831b57 commit 3c98704

File tree

3 files changed

+52
-2
lines changed

3 files changed

+52
-2
lines changed

mysql-test/suite/innodb/r/innodb-alter.result

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -860,3 +860,32 @@ DROP TABLE dest_db.t1;
860860
DROP TABLE source_db.t1;
861861
DROP DATABASE source_db;
862862
DROP DATABASE dest_db;
863+
#
864+
# BUG #26334149 MYSQL CRASHES WHEN FULL TEXT INDEXES IBD FILES ARE
865+
# ORPHANED DUE TO RENAME TABLE
866+
#
867+
CREATE DATABASE db1;
868+
USE db1;
869+
CREATE TABLE notes (
870+
id int(11) NOT NULL AUTO_INCREMENT,
871+
body text COLLATE utf8_unicode_ci,
872+
PRIMARY KEY (id)
873+
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8
874+
COLLATE=utf8_unicode_ci
875+
ROW_FORMAT=COMPRESSED;
876+
Warnings:
877+
Warning 1478 InnoDB: ROW_FORMAT=COMPRESSED requires innodb_file_format > Antelope.
878+
Warning 1478 InnoDB: assuming ROW_FORMAT=COMPACT.
879+
ALTER TABLE notes ADD FULLTEXT INDEX index_ft_body (body(255));
880+
Warnings:
881+
Warning 1478 InnoDB: ROW_FORMAT=COMPRESSED requires innodb_file_format > Antelope.
882+
Warning 1478 InnoDB: assuming ROW_FORMAT=COMPACT.
883+
Warning 124 InnoDB rebuilding table to add column FTS_DOC_ID
884+
DROP INDEX index_ft_body ON notes;
885+
Warnings:
886+
Warning 1478 InnoDB: ROW_FORMAT=COMPRESSED requires innodb_file_format > Antelope.
887+
Warning 1478 InnoDB: assuming ROW_FORMAT=COMPACT.
888+
CREATE DATABASE db2;
889+
RENAME TABLE db1.notes TO db2.notes;
890+
DROP DATABASE db1;
891+
DROP DATABASE db2;

mysql-test/suite/innodb/t/innodb-alter.test

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,5 +480,25 @@ eval DROP TABLE $source_db.t1;
480480
eval DROP DATABASE $source_db;
481481
eval DROP DATABASE $dest_db;
482482

483+
--echo #
484+
--echo # BUG #26334149 MYSQL CRASHES WHEN FULL TEXT INDEXES IBD FILES ARE
485+
--echo # ORPHANED DUE TO RENAME TABLE
486+
--echo #
487+
CREATE DATABASE db1; USE db1;
488+
CREATE TABLE notes (
489+
id int(11) NOT NULL AUTO_INCREMENT,
490+
body text COLLATE utf8_unicode_ci,
491+
PRIMARY KEY (id)
492+
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8
493+
COLLATE=utf8_unicode_ci
494+
ROW_FORMAT=COMPRESSED;
495+
496+
ALTER TABLE notes ADD FULLTEXT INDEX index_ft_body (body(255));
497+
DROP INDEX index_ft_body ON notes;
498+
499+
CREATE DATABASE db2;
500+
RENAME TABLE db1.notes TO db2.notes;
501+
DROP DATABASE db1;
502+
DROP DATABASE db2;
483503

484504

storage/innobase/row/row0mysql.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*****************************************************************************
22
3-
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All Rights Reserved.
3+
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All Rights Reserved.
44
55
This program is free software; you can redistribute it and/or modify it under
66
the terms of the GNU General Public License as published by the Free Software
@@ -5085,7 +5085,8 @@ row_rename_table_for_mysql(
50855085
}
50865086
}
50875087

5088-
if (dict_table_has_fts_index(table)
5088+
if ((dict_table_has_fts_index(table)
5089+
|| DICT_TF2_FLAG_IS_SET(table, DICT_TF2_FTS_HAS_DOC_ID))
50895090
&& !dict_tables_have_same_db(old_name, new_name)) {
50905091
err = fts_rename_aux_tables(table, new_name, trx);
50915092
if (err != DB_TABLE_NOT_FOUND) {

0 commit comments

Comments
 (0)