Bug #121939 Dropping two FULLTEXT indexes leaves orphan InnoDB dictionary rows

Submitted: 26 Nov 2:52
Reporter: QiFan Liu Email Updates:
Status: Open Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S2 (Serious)
Version:26.10.0 OS:Linux
Assigned to: CPU Architecture:x86
Tags: ALTER TABLE, data dictionary, drop index, fulltext

[26 Nov 2:52] QiFan Liu
Description:
Dropping two FULLTEXT indexes in one ALTER TABLE succeeds, but the six auxiliary tables belonging to the first dropped index remain in information_schema.innodb_tables.

On a clean test schema, the observed counts were:

aux_before: 17
aux_after: 11
dropped_index_aux_after: 6

After DROP DATABASE succeeds, the schema is absent from information_schema.schemata, but the same six index-specific InnoDB dictionary rows remain. Recreating and dropping the empty database does not remove them. Attempting to drop a hidden auxiliary table reports that the table is unknown, while the server log reports MY-012216 because its .ibd file does not exist.

The ALTER should remove the auxiliary dictionary entries for both indexes. Common FTS tables are excluded from the failing count because they may remain while the internal FTS_DOC_ID infrastructure exists.

Related issue: #36559642 appears related to this cleanup path, but this report specifically concerns cleanup records being lost when multiple FULLTEXT indexes are dropped by one ALTER TABLE.

How to repeat:
Run as root in a fresh mysql session:

DROP DATABASE IF EXISTS db1;
CREATE DATABASE db1;
USE db1;

CREATE TABLE t1 (
  id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
  a TEXT NOT NULL,
  b TEXT NOT NULL,
  FULLTEXT KEY fa (a),
  FULLTEXT KEY fb (b)
) ENGINE=InnoDB;

INSERT INTO t1(a,b) VALUES ('alpha sharedword', 'beta sharedword');

SELECT COUNT(*) AS a_matches
FROM t1
WHERE MATCH(a) AGAINST ('sharedword');

SELECT COUNT(*) AS b_matches
FROM t1
WHERE MATCH(b) AGAINST ('sharedword');

ALTER TABLE t1
  DROP INDEX fa,
  DROP INDEX fb;

SELECT COUNT(*) AS dropped_index_aux_after
FROM information_schema.innodb_tables
WHERE NAME LIKE 'db1/FTS\_%' ESCAPE '\\'
  AND NAME REGEXP '_index_[1-6]$';
-- observed: 6
-- expected: 0

SELECT NAME AS orphan_name
FROM information_schema.innodb_tables
WHERE NAME LIKE 'db1/FTS\_%' ESCAPE '\\'
  AND NAME REGEXP '_index_[1-6]$'
ORDER BY NAME;
-- observed: six names ending in _index_1 through _index_6

DROP DATABASE db1;

SELECT COUNT(*) AS schema_rows
FROM information_schema.schemata
WHERE schema_name = 'db1';
-- observed: 0

SELECT COUNT(*) AS orphan_rows_after_drop_database
FROM information_schema.innodb_tables
WHERE NAME LIKE 'db1/FTS\_%' ESCAPE '\\'
  AND NAME REGEXP '_index_[1-6]$';
-- observed: 6
-- expected: 0

Suggested fix:
Retain and process the deferred auxiliary-table cleanup names for every FULLTEXT index dropped by the ALTER, rather than replacing the previously collected names when the next dropped index is handled.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.039 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.