Commit b737d902 authored by Sergey Vojtovich's avatar Sergey Vojtovich

MDEV-6774 - Deadlock between SELECT, DROP TABLE, SHOW STATUS and

            SET @@global.log_output

Deadlock chain:
rdlock(LOCK_logger) -> lock(LOCK_open)     SELECT 1
lock(LOCK_open)     -> lock(LOCK_status)   DROP TABLE t1
lock(LOCK_status)   -> lock(LOCK_g_s_v)    SHOW STATUS
lock(LOCK_g_s_)     -> wrlock(LOCK_logger) SET @@global.log_output=DEFAULT

Fixed by removing relationship between LOCK_status and
LOCK_global_system_variables during SHOW STATUS: we don't really need
LOCK_global_system_variables when accessing status vars.
parent d1e46a50
...@@ -355,14 +355,7 @@ Event_scheduler::Event_scheduler(Event_queue *queue_arg) ...@@ -355,14 +355,7 @@ Event_scheduler::Event_scheduler(Event_queue *queue_arg)
mysql_mutex_init(key_event_scheduler_LOCK_scheduler_state, mysql_mutex_init(key_event_scheduler_LOCK_scheduler_state,
&LOCK_scheduler_state, MY_MUTEX_INIT_FAST); &LOCK_scheduler_state, MY_MUTEX_INIT_FAST);
mysql_cond_init(key_event_scheduler_COND_state, &COND_state, NULL); mysql_cond_init(key_event_scheduler_COND_state, &COND_state, NULL);
mysql_mutex_record_order(&LOCK_scheduler_state, &LOCK_global_system_variables);
#ifdef SAFE_MUTEX
/* Ensure right mutex order */
mysql_mutex_lock(&LOCK_scheduler_state);
mysql_mutex_lock(&LOCK_global_system_variables);
mysql_mutex_unlock(&LOCK_global_system_variables);
mysql_mutex_unlock(&LOCK_scheduler_state);
#endif
} }
......
...@@ -2648,12 +2648,11 @@ static bool show_status_array(THD *thd, const char *wild, ...@@ -2648,12 +2648,11 @@ static bool show_status_array(THD *thd, const char *wild,
char *value=var->value; char *value=var->value;
const char *pos, *end; // We assign a lot of const's const char *pos, *end; // We assign a lot of const's
mysql_mutex_lock(&LOCK_global_system_variables);
if (show_type == SHOW_SYS) if (show_type == SHOW_SYS)
{ {
sys_var *var= ((sys_var *) value); sys_var *var= ((sys_var *) value);
show_type= var->show_type(); show_type= var->show_type();
mysql_mutex_lock(&LOCK_global_system_variables);
value= (char*) var->value_ptr(thd, value_type, &null_lex_str); value= (char*) var->value_ptr(thd, value_type, &null_lex_str);
charset= var->charset(thd); charset= var->charset(thd);
} }
...@@ -2754,7 +2753,8 @@ static bool show_status_array(THD *thd, const char *wild, ...@@ -2754,7 +2753,8 @@ static bool show_status_array(THD *thd, const char *wild,
thd->count_cuted_fields= CHECK_FIELD_IGNORE; thd->count_cuted_fields= CHECK_FIELD_IGNORE;
table->field[1]->set_notnull(); table->field[1]->set_notnull();
mysql_mutex_unlock(&LOCK_global_system_variables); if (var->type == SHOW_SYS)
mysql_mutex_unlock(&LOCK_global_system_variables);
if (schema_table_store_record(thd, table)) if (schema_table_store_record(thd, table))
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment