Skip to content

Commit 7285b4c

Browse files
committed
Bug#20788853 MUTEX ISSUE IN SQL/SQL_SHOW.CC RESULTING IN SIG6. SOURCE LIKELY
FILL_VARIABLES Prevent mutexes used in SHOW VARIABLES from being locked twice.
1 parent 45b5114 commit 7285b4c

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

sql/sql_class.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,7 @@ THD::THD()
802802
rli_fake(0), rli_slave(NULL),
803803
user_time(0), in_sub_stmt(0),
804804
fill_status_recursion_level(0),
805+
fill_variables_recursion_level(0),
805806
binlog_unsafe_warning_flags(0),
806807
binlog_table_maps(0),
807808
table_map_for_update(0),

sql/sql_class.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1603,6 +1603,7 @@ class THD :public Statement,
16031603
decremented each time before it returns from the function.
16041604
*/
16051605
uint fill_status_recursion_level;
1606+
uint fill_variables_recursion_level;
16061607

16071608
/* container for handler's private per-connection data */
16081609
Ha_data ha_data[MAX_HA];

sql/sql_show.cc

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6317,7 +6317,11 @@ int fill_variables(THD *thd, TABLE_LIST *tables, COND *cond)
63176317
Lock LOCK_plugin_delete to avoid deletion of any plugins while creating
63186318
SHOW_VAR array and hold it until all variables are stored in the table.
63196319
*/
6320-
mysql_mutex_lock(&LOCK_plugin_delete);
6320+
if (thd->fill_variables_recursion_level++ == 0)
6321+
{
6322+
mysql_mutex_lock(&LOCK_plugin_delete);
6323+
}
6324+
63216325
// Lock LOCK_system_variables_hash to prepare SHOW_VARs array.
63226326
mysql_rwlock_rdlock(&LOCK_system_variables_hash);
63236327
DEBUG_SYNC(thd, "acquired_LOCK_system_variables_hash");
@@ -6327,7 +6331,11 @@ int fill_variables(THD *thd, TABLE_LIST *tables, COND *cond)
63276331
res= show_status_array(thd, wild, sys_var_array, option_type, NULL, "",
63286332
tables->table, upper_case_names, cond);
63296333

6330-
mysql_mutex_unlock(&LOCK_plugin_delete);
6334+
if (thd->fill_variables_recursion_level-- == 1)
6335+
{
6336+
mysql_mutex_unlock(&LOCK_plugin_delete);
6337+
}
6338+
63316339
DBUG_RETURN(res);
63326340
}
63336341

0 commit comments

Comments
 (0)