Skip to content

Commit 197bf0f

Browse files
sachinagarwal1111dr-m
authored andcommitted
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 : Jimmy.Yang@oracle.com
1 parent 9c03ba8 commit 197bf0f

File tree

3 files changed

+53
-2
lines changed

3 files changed

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

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,3 +481,24 @@ eval ALTER TABLE $source_db.t1 DROP INDEX index2, algorithm=inplace;
481481
eval DROP TABLE $source_db.t1;
482482
eval DROP DATABASE $source_db;
483483
eval DROP DATABASE $dest_db;
484+
485+
--echo #
486+
--echo # BUG #26334149 MYSQL CRASHES WHEN FULL TEXT INDEXES IBD FILES ARE
487+
--echo # ORPHANED DUE TO RENAME TABLE
488+
--echo #
489+
CREATE DATABASE db1; USE db1;
490+
CREATE TABLE notes (
491+
id int(11) NOT NULL AUTO_INCREMENT,
492+
body text COLLATE utf8_unicode_ci,
493+
PRIMARY KEY (id)
494+
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8
495+
COLLATE=utf8_unicode_ci
496+
ROW_FORMAT=COMPRESSED;
497+
498+
ALTER TABLE notes ADD FULLTEXT INDEX index_ft_body (body(255));
499+
DROP INDEX index_ft_body ON notes;
500+
501+
CREATE DATABASE db2;
502+
RENAME TABLE db1.notes TO db2.notes;
503+
DROP DATABASE db1;
504+
DROP DATABASE db2;

storage/xtradb/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
Copyright (c) 2017, 2018, MariaDB Corporation.
55
66
This program is free software; you can redistribute it and/or modify it under
@@ -5168,7 +5168,8 @@ row_rename_table_for_mysql(
51685168
}
51695169
}
51705170

5171-
if (dict_table_has_fts_index(table)
5171+
if ((dict_table_has_fts_index(table)
5172+
|| DICT_TF2_FLAG_IS_SET(table, DICT_TF2_FTS_HAS_DOC_ID))
51725173
&& !dict_tables_have_same_db(old_name, new_name)) {
51735174
err = fts_rename_aux_tables(table, new_name, trx);
51745175
if (err != DB_TABLE_NOT_FOUND) {

0 commit comments

Comments
 (0)