Skip to content

Commit 48fd2d7

Browse files
george-reynyafacebook-github-bot
authored andcommitted
Convert mutex LOCK_plugin_install into MDL_mutex
Summary: Convert LOCK_plugin_install to thread pool friendly MDL_mutex. While this mutex is held the code can run arbitrary queries which could yield/suspend the scheduler. Differential Revision: D46255827 fbshipit-source-id: 1ee126a
1 parent d70edeb commit 48fd2d7

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

sql/sql_plugin.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,7 @@ mysql_mutex_t LOCK_plugin;
453453
Must be taken before LOCK_plugin.
454454
*/
455455
mysql_mutex_t LOCK_plugin_install;
456+
MDL_mutex mutex_plugin_install;
456457
static Prealloced_array<st_plugin_dl *, 16> *plugin_dl_array;
457458
static Prealloced_array<st_plugin_int *, 16> *plugin_array;
458459
static collation_unordered_map<std::string, st_plugin_int *>
@@ -1406,6 +1407,7 @@ static bool plugin_init_internals() {
14061407
MY_MUTEX_INIT_FAST);
14071408
mysql_mutex_init(key_LOCK_plugin_install, &LOCK_plugin_install,
14081409
MY_MUTEX_INIT_FAST);
1410+
mutex_plugin_install.init("PLUGIN_INSTALL");
14091411

14101412
plugin_dl_array = new (std::nothrow)
14111413
Prealloced_array<st_plugin_dl *, 16>(key_memory_mysql_plugin_dl);
@@ -2324,7 +2326,7 @@ static bool mysql_install_plugin(THD *thd, LEX_CSTRING name,
23242326
mysql_audit_acquire_plugins(thd, MYSQL_AUDIT_GENERAL_CLASS,
23252327
MYSQL_AUDIT_GENERAL_ALL);
23262328

2327-
mysql_mutex_lock(&LOCK_plugin_install);
2329+
MDL_mutex_guard guard(&mutex_plugin_install, thd, &LOCK_plugin_install);
23282330
mysql_mutex_lock(&LOCK_plugin);
23292331
DEBUG_SYNC(thd, "acquired_LOCK_plugin");
23302332
mysql_rwlock_wrlock(&LOCK_system_variables_hash);
@@ -2461,7 +2463,6 @@ static bool mysql_install_plugin(THD *thd, LEX_CSTRING name,
24612463
}
24622464

24632465
err:
2464-
mysql_mutex_unlock(&LOCK_plugin_install);
24652466
return end_transaction(thd, error);
24662467
}
24672468

@@ -2519,7 +2520,7 @@ static bool mysql_uninstall_plugin(THD *thd, LEX_CSTRING name) {
25192520
if (table_intact.check(thd, table, &mysql_plugin_table_def))
25202521
return end_transaction(thd, error);
25212522

2522-
mysql_mutex_lock(&LOCK_plugin_install);
2523+
MDL_mutex_guard guard(&mutex_plugin_install, thd, &LOCK_plugin_install);
25232524
if (!table->key_info) {
25242525
my_error(ER_MISSING_KEY, MYF(0), table->s->db.str,
25252526
table->s->table_name.str);
@@ -2679,7 +2680,6 @@ static bool mysql_uninstall_plugin(THD *thd, LEX_CSTRING name) {
26792680
}
26802681

26812682
err:
2682-
mysql_mutex_unlock(&LOCK_plugin_install);
26832683
return end_transaction(thd, error || thd->transaction_rollback_request);
26842684
}
26852685

0 commit comments

Comments
 (0)