[MDEV-26274] On timeout, fts_lock_table() attempts to release unreserved dict_sys.mutex Created: 2021-07-29  Updated: 2021-07-29  Resolved: 2021-07-29

Status: Closed
Project: MariaDB Server
Component/s: Full-text Search, Storage Engine - InnoDB
Affects Version/s: 10.6.2, 10.6.3
Fix Version/s: 10.6.4

Type: Bug Priority: Blocker
Reporter: Marko Mäkelä Assignee: Marko Mäkelä
Resolution: Fixed Votes: 0
Labels: regression-10.6

Issue Links:
Problem/Incident
is caused by MDEV-25936 Crash during DDL that involves FULLTE... Closed

 Description   

In MDEV-25936, we inadvertently introduced a problem that would cause safe_mutex failures in workloads that involve DDL on tables that contain FULLTEXT INDEX. The fix describes it best:

diff --git a/storage/innobase/fts/fts0fts.cc b/storage/innobase/fts/fts0fts.cc
index 21a3567f33a..885b0432ebf 100644
--- a/storage/innobase/fts/fts0fts.cc
+++ b/storage/innobase/fts/fts0fts.cc
@@ -1556,12 +1556,13 @@ static dberr_t fts_lock_table(trx_t *trx, const char *table_name)
       if (!--n)
       {
         err= DB_LOCK_WAIT_TIMEOUT;
-        break;
+        goto fail;
       }
       std::this_thread::sleep_for(std::chrono::milliseconds(50));
       dict_sys.mutex_lock();
     }
     dict_sys.mutex_unlock();
+fail:
     table->release();
     return err;
   }

If a timeout occurs, we would wrongly attempt to release {{dict_sys.mutex}, which the current thread is not holding.
The failure would look something like this:

safe_mutex: Trying to unlock mutex mutex that wasn't locked at /data/Server/bb-10.6-MDEV-25919/storage/innobase/include/dict0dict.h, line 1570


Generated at Thu Feb 08 09:44:03 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.