Bug #119661 Drop multiple FTS will cause permanent leakage of its AUX tables
Submitted: 12 Jan 13:19
Reporter: Ruyi Zhang (OCA) Email Updates:
Status: Open Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S2 (Serious)
Version:8.0.44 OS:Any
Assigned to: CPU Architecture:Any
Tags: fts

[12 Jan 13:19] Ruyi Zhang
Description:
We noticed that dropping multiple FTS in one query causes leaks of their AUX tables. 

The leaked AUX tables cannot be removed from the DD system, even after dropping their parent tables.

This will also cause a small amount of memory leakage.

How to repeat:
mtr

```
create table t(id int primary key, fts1 text, fts2 text, fts3 text, FULLTEXT KEY(fts1), FULLTEXT KEY(fts2), FULLTEXT KEY(fts3)) engine=innodb;
alter table t drop index fts2, drop index fts3;
drop table t;
select count(1) from information_schema.innodb_tables where name like 'fts_%';
```

`select count(1) from information_schema.innodb_tables where name like 'fts_%';` returns a value > 0 due to leaked AUX tables in the system.

Suggested fix:
ex aebe98961a3..a6181a8a781 100644
--- a/storage/innobase/handler/handler0alter.cc
+++ b/storage/innobase/handler/handler0alter.cc
@@ -7244,7 +7244,9 @@ after a successful commit_try_norebuild() call.
       if (index->type & DICT_FTS) {
         assert(index->type == DICT_FTS || index->is_corrupted());
         assert(index->table->fts);
-        ctx->fts_drop_aux_vec = new aux_name_vec_t;
+        if (ctx->fts_drop_aux_vec == nullptr) {
+          ctx->fts_drop_aux_vec = new aux_name_vec_t;
+        }
         fts_drop_index(index->table, index, trx, ctx->fts_drop_aux_vec,
                        adding_fts_index);
       }