Commit bde11c1a authored by Sergey Vojtovich's avatar Sergey Vojtovich

MDEV-5089 - possible deadlocks between rwlocks and mutexes

Pre-MDL versions had direct relationship between LOCK_open and
LOCK_global_system_variables, e.g.:
  intern_sys_var_ptr // locks LOCK_global_system_variable
  mysql_sys_var_char
  create_options_are_valid
  ha_innobase::create
  handler::ha_create
  ha_create_table
  rea_create_table
  mysql_create_table_no_lock // locks LOCK_open
  mysql_create_table

With MDL this relationship was removed, but mutex order was still
recorded. In fact there is indirect relationship between LOCK_open
and LOCK_global_system_variables via rwlocks in reverse order.

Removed LOCK_open and LOCK_global_system_variables order recording,
instead assert that LOCK_open is never held in intern_sys_var_ptr().

This solves only one of many problems detected with MDEV-5089.
parent b0b699dc
......@@ -5040,12 +5040,6 @@ int mysqld_main(int argc, char **argv)
unireg_abort(1);
}
/*
We must have LOCK_open before LOCK_global_system_variables because
LOCK_open is hold while sql_plugin.c::intern_sys_var_ptr() is called.
*/
mysql_mutex_record_order(&LOCK_open, &LOCK_global_system_variables);
create_shutdown_thread();
start_handle_manager();
......
......@@ -2900,6 +2900,7 @@ static uchar *intern_sys_var_ptr(THD* thd, int offset, bool global_lock)
DBUG_ENTER("intern_sys_var_ptr");
DBUG_ASSERT(offset >= 0);
DBUG_ASSERT((uint)offset <= global_system_variables.dynamic_variables_head);
mysql_mutex_assert_not_owner(&LOCK_open);
if (!thd)
DBUG_RETURN((uchar*) global_system_variables.dynamic_variables_ptr + offset);
......
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