From a4b0301b91e1b86adce58a6b9cda653c471aa46a Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Wed, 11 Jun 2025 20:47:43 +0530 Subject: [PATCH] MDEV-30363 InnoDB: Failing assertion: trx->error_state == DB_SUCCESS in que_run_threads Problem: ========= - During truncation of a fulltext table, InnoDB does create the table and does insert the default config fts values in fulltext common config table using create table transaction. - Before committing the create table transaction, InnoDB does update the dictionary by loading the stopword into fts cache and write the stopword configuration into fulltext common config table by creating a separate transaction. This leads to lock wait timeout error and rollbacks the transaction. - But truncate table holds dict_sys.lock and rollback also tries to acquire dict_sys.lock. This leads to assertion during rollback. Solution: ========= ha_innobase::truncate(): Commit the create table transaction before updating the dictionary after create table. --- .../suite/innodb_fts/r/innodb_fts_misc_1.result | 12 ++++++++++++ .../suite/innodb_fts/t/innodb_fts_misc_1.test | 13 +++++++++++++ storage/innobase/handler/ha_innodb.cc | 2 +- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/mysql-test/suite/innodb_fts/r/innodb_fts_misc_1.result b/mysql-test/suite/innodb_fts/r/innodb_fts_misc_1.result index 52cbede7314..52bd819286f 100644 --- a/mysql-test/suite/innodb_fts/r/innodb_fts_misc_1.result +++ b/mysql-test/suite/innodb_fts/r/innodb_fts_misc_1.result @@ -993,3 +993,15 @@ FTS_DOC_ID f1 f2 4294967298 txt bbb 100000000000 aaa bbb DROP TABLE t1; +# +# MDEV-30363 Failing assertion: trx->error_state == DB_SUCCESS +# in que_run_threads +# +CREATE TABLE server_stopword (value VARCHAR(1))engine=innodb; +SET GLOBAL innodb_ft_server_stopword_table='test/server_stopword'; +CREATE TABLE t (t VARCHAR(1) COLLATE utf8_unicode_ci, +FULLTEXT (t))engine=innodb; +TRUNCATE TABLE t; +DROP TABLE t; +DROP TABLE server_stopword; +SET GLOBAL innodb_ft_server_stopword_table= default; diff --git a/mysql-test/suite/innodb_fts/t/innodb_fts_misc_1.test b/mysql-test/suite/innodb_fts/t/innodb_fts_misc_1.test index 4eaf5b2e0bd..7f2c21ee404 100644 --- a/mysql-test/suite/innodb_fts/t/innodb_fts_misc_1.test +++ b/mysql-test/suite/innodb_fts/t/innodb_fts_misc_1.test @@ -967,3 +967,16 @@ CREATE FULLTEXT INDEX i ON t1 (f2); SELECT * FROM t1 WHERE match(f2) against("bbb"); # Cleanup DROP TABLE t1; + +--echo # +--echo # MDEV-30363 Failing assertion: trx->error_state == DB_SUCCESS +--echo # in que_run_threads +--echo # +CREATE TABLE server_stopword (value VARCHAR(1))engine=innodb; +SET GLOBAL innodb_ft_server_stopword_table='test/server_stopword'; +CREATE TABLE t (t VARCHAR(1) COLLATE utf8_unicode_ci, + FULLTEXT (t))engine=innodb; +TRUNCATE TABLE t; +DROP TABLE t; +DROP TABLE server_stopword; +SET GLOBAL innodb_ft_server_stopword_table= default; diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 7e8eef467cf..3f84070064f 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -14088,10 +14088,10 @@ int ha_innobase::truncate() trx); if (!err) { + trx->commit(deleted); m_prebuilt->table->acquire(); create_table_info_t::create_table_update_dict(m_prebuilt->table, m_user_thd, info, *table); - trx->commit(deleted); } else {