Skip to content

Commit be10363

Browse files
george-reynyaHerman Lee
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
1 parent 3ed5040 commit be10363

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
@@ -454,6 +454,7 @@ mysql_mutex_t LOCK_plugin;
454454
Must be taken before LOCK_plugin.
455455
*/
456456
mysql_mutex_t LOCK_plugin_install;
457+
MDL_mutex mutex_plugin_install;
457458
static Prealloced_array<st_plugin_dl *, 16> *plugin_dl_array;
458459
static Prealloced_array<st_plugin_int *, 16> *plugin_array;
459460
static collation_unordered_map<std::string, st_plugin_int *>
@@ -1418,6 +1419,7 @@ static bool plugin_init_internals() {
14181419
MY_MUTEX_INIT_FAST);
14191420
mysql_mutex_init(key_LOCK_plugin_install, &LOCK_plugin_install,
14201421
MY_MUTEX_INIT_FAST);
1422+
mutex_plugin_install.init("PLUGIN_INSTALL");
14211423

14221424
plugin_dl_array = new (std::nothrow)
14231425
Prealloced_array<st_plugin_dl *, 16>(key_memory_mysql_plugin_dl);
@@ -2389,7 +2391,7 @@ static bool mysql_install_plugin(THD *thd, LEX_CSTRING name,
23892391
mysql_audit_acquire_plugins(thd, MYSQL_AUDIT_GENERAL_CLASS,
23902392
MYSQL_AUDIT_GENERAL_ALL);
23912393

2392-
mysql_mutex_lock(&LOCK_plugin_install);
2394+
MDL_mutex_guard guard(&mutex_plugin_install, thd, &LOCK_plugin_install);
23932395
mysql_rwlock_wrlock(&LOCK_system_variables_hash);
23942396
mysql_mutex_lock(&LOCK_plugin);
23952397

@@ -2535,7 +2537,6 @@ static bool mysql_install_plugin(THD *thd, LEX_CSTRING name,
25352537
}
25362538

25372539
err:
2538-
mysql_mutex_unlock(&LOCK_plugin_install);
25392540
return end_transaction(thd, error);
25402541
}
25412542

@@ -2593,7 +2594,7 @@ static bool mysql_uninstall_plugin(THD *thd, LEX_CSTRING name) {
25932594
if (table_intact.check(thd, table, &mysql_plugin_table_def))
25942595
return end_transaction(thd, error);
25952596

2596-
mysql_mutex_lock(&LOCK_plugin_install);
2597+
MDL_mutex_guard guard(&mutex_plugin_install, thd, &LOCK_plugin_install);
25972598
if (!table->key_info) {
25982599
my_error(ER_MISSING_KEY, MYF(0), table->s->db.str,
25992600
table->s->table_name.str);
@@ -2753,7 +2754,6 @@ static bool mysql_uninstall_plugin(THD *thd, LEX_CSTRING name) {
27532754
}
27542755

27552756
err:
2756-
mysql_mutex_unlock(&LOCK_plugin_install);
27572757
return end_transaction(thd, error || thd->transaction_rollback_request);
27582758
}
27592759

0 commit comments

Comments
 (0)