MDEV-450: Deadlock between starting a slave and reading system variables
Starting the SQL thread might deadlock with reading the values of the replication filtering options. The deadlock is due to a lock order violation when the variables are read or set. For example, reading replicate_ignore_table first acquires LOCK_global_system_variables in sys_var::value_ptr and later acquires LOCK_active_mi in Sys_var_rpl_filter::global_value_ptr. This violates the order established when starting a SQL thread, where LOCK_active_mi is acquired before start_slave, and ends up creating a thread (handle_slave_sql) that allocates a THD handle whose constructor acquires LOCK_global_system_variables in THD::init. The solution is to unlock LOCK_global_system_variables before the replication filtering options are set or read. This way the lock order is preserved and the data being read/set is still protected given that it acquires LOCK_active_mi.
Showing
Please register or sign in to comment