Commit 1f08be94 authored by unknown's avatar unknown

MDEV-26: Global transaction ID

Fix lock order violation. Make sure we temporarily release
LOCK_global_system_variables before taking LOCK_active_mi.
Otherwise we get a lock dependency cycle when we use
open_tables() under LOCK_active_mi.
parent 2cf3d61f
...@@ -4005,6 +4005,7 @@ static int init_thread_environment() ...@@ -4005,6 +4005,7 @@ static int init_thread_environment()
mysql_mutex_init(key_LOCK_active_mi, &LOCK_active_mi, MY_MUTEX_INIT_FAST); mysql_mutex_init(key_LOCK_active_mi, &LOCK_active_mi, MY_MUTEX_INIT_FAST);
mysql_mutex_init(key_LOCK_global_system_variables, mysql_mutex_init(key_LOCK_global_system_variables,
&LOCK_global_system_variables, MY_MUTEX_INIT_FAST); &LOCK_global_system_variables, MY_MUTEX_INIT_FAST);
mysql_mutex_record_order(&LOCK_active_mi, &LOCK_global_system_variables);
mysql_rwlock_init(key_rwlock_LOCK_system_variables_hash, mysql_rwlock_init(key_rwlock_LOCK_system_variables_hash,
&LOCK_system_variables_hash); &LOCK_system_variables_hash);
mysql_mutex_init(key_LOCK_prepared_stmt_count, mysql_mutex_init(key_LOCK_prepared_stmt_count,
......
...@@ -379,6 +379,7 @@ bool table_def_init(void) ...@@ -379,6 +379,7 @@ bool table_def_init(void)
init_tdc_psi_keys(); init_tdc_psi_keys();
#endif #endif
mysql_mutex_init(key_LOCK_open, &LOCK_open, MY_MUTEX_INIT_FAST); mysql_mutex_init(key_LOCK_open, &LOCK_open, MY_MUTEX_INIT_FAST);
mysql_mutex_record_order(&LOCK_active_mi, &LOCK_open);
oldest_unused_share= &end_of_unused_share; oldest_unused_share= &end_of_unused_share;
end_of_unused_share.prev= &oldest_unused_share; end_of_unused_share.prev= &oldest_unused_share;
......
...@@ -3400,6 +3400,7 @@ get_master_info_uint_value(THD *thd, ptrdiff_t offset) ...@@ -3400,6 +3400,7 @@ get_master_info_uint_value(THD *thd, ptrdiff_t offset)
{ {
Master_info *mi; Master_info *mi;
uint res= 0; // Default value uint res= 0; // Default value
mysql_mutex_unlock(&LOCK_global_system_variables);
mysql_mutex_lock(&LOCK_active_mi); mysql_mutex_lock(&LOCK_active_mi);
mi= master_info_index-> mi= master_info_index->
get_master_info(&thd->variables.default_master_connection, get_master_info(&thd->variables.default_master_connection,
...@@ -3411,6 +3412,7 @@ get_master_info_uint_value(THD *thd, ptrdiff_t offset) ...@@ -3411,6 +3412,7 @@ get_master_info_uint_value(THD *thd, ptrdiff_t offset)
mysql_mutex_unlock(&mi->rli.data_lock); mysql_mutex_unlock(&mi->rli.data_lock);
} }
mysql_mutex_unlock(&LOCK_active_mi); mysql_mutex_unlock(&LOCK_active_mi);
mysql_mutex_lock(&LOCK_global_system_variables);
return res; return res;
} }
...@@ -3422,6 +3424,7 @@ bool update_multi_source_variable(sys_var *self_var, THD *thd, ...@@ -3422,6 +3424,7 @@ bool update_multi_source_variable(sys_var *self_var, THD *thd,
bool result= true; bool result= true;
Master_info *mi; Master_info *mi;
mysql_mutex_unlock(&LOCK_global_system_variables);
mysql_mutex_lock(&LOCK_active_mi); mysql_mutex_lock(&LOCK_active_mi);
mi= master_info_index-> mi= master_info_index->
get_master_info(&thd->variables.default_master_connection, get_master_info(&thd->variables.default_master_connection,
...@@ -3435,6 +3438,7 @@ bool update_multi_source_variable(sys_var *self_var, THD *thd, ...@@ -3435,6 +3438,7 @@ bool update_multi_source_variable(sys_var *self_var, THD *thd,
mysql_mutex_unlock(&mi->rli.run_lock); mysql_mutex_unlock(&mi->rli.run_lock);
} }
mysql_mutex_unlock(&LOCK_active_mi); mysql_mutex_unlock(&LOCK_active_mi);
mysql_mutex_lock(&LOCK_global_system_variables);
return result; return result;
} }
......
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