MDEV-21563 FTS thread aborts during shutdown

Problem:
=======
After discarding the table, fts_optimize_thread aborts during shutdown.
InnoDB fails to remove the table from fts_optimize_wq and it leads to
the fts_optimize_thread to lookup for the auxiliary table and fails.

Fix:
====
While discarding the fts table, remove the table from fts_optimize_wq.
parent 0b36c27e
......@@ -3205,6 +3205,16 @@ row_discard_tablespace_for_mysql(
err = DB_ERROR;
} else {
bool fts_exist = (dict_table_has_fts_index(table)
|| DICT_TF2_FLAG_IS_SET(
table, DICT_TF2_FTS_HAS_DOC_ID));
if (fts_exist) {
row_mysql_unlock_data_dictionary(trx);
fts_optimize_remove_table(table);
row_mysql_lock_data_dictionary(trx);
}
/* Do foreign key constraint checks. */
err = row_discard_tablespace_foreign_key_checks(trx, table);
......@@ -3212,6 +3222,10 @@ row_discard_tablespace_for_mysql(
if (err == DB_SUCCESS) {
err = row_discard_tablespace(trx, table);
}
if (fts_exist && err != DB_SUCCESS) {
fts_optimize_add_table(table);
}
}
return(row_discard_tablespace_end(trx, table, err));
......
......@@ -3209,6 +3209,16 @@ row_discard_tablespace_for_mysql(
err = DB_ERROR;
} else {
bool fts_exist = (dict_table_has_fts_index(table)
|| DICT_TF2_FLAG_IS_SET(
table, DICT_TF2_FTS_HAS_DOC_ID));
if (fts_exist) {
row_mysql_unlock_data_dictionary(trx);
fts_optimize_remove_table(table);
row_mysql_lock_data_dictionary(trx);
}
/* Do foreign key constraint checks. */
err = row_discard_tablespace_foreign_key_checks(trx, table);
......@@ -3216,6 +3226,11 @@ row_discard_tablespace_for_mysql(
if (err == DB_SUCCESS) {
err = row_discard_tablespace(trx, table);
}
if (fts_exist && err != DB_SUCCESS) {
fts_optimize_add_table(table);
}
}
return(row_discard_tablespace_end(trx, table, err));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment