mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
MDEV-12179: Per-engine mysql.gtid_slave_pos table
Intermediate commit. Move the discovery of mysql.gtid_slave_pos* tables into the SQL thread. This avoids doing things like opening tables and scanning the mysql schema for tables inside of the START SLAVE statement, which might interact badly with existing transaction or table locks. (Even though START SLAVE is documented to implicitly commit any active transactions, this appears not to be the case in current code). Table discovery fits naturally in the SQL thread init code, next to the loading of mysql.gtid_slave_pos state.
This commit is contained in:
@ -1558,6 +1558,9 @@ bool give_error_if_slave_running(bool already_locked)
|
||||
/**
|
||||
any_slave_sql_running()
|
||||
|
||||
@param
|
||||
already_locked 0 if we need to lock, 1 if we have LOCK_active_mi_locked
|
||||
|
||||
@return
|
||||
0 No Slave SQL thread is running
|
||||
# Number of slave SQL thread running
|
||||
@ -1568,26 +1571,28 @@ bool give_error_if_slave_running(bool already_locked)
|
||||
hash entries can't be accessed.
|
||||
*/
|
||||
|
||||
uint any_slave_sql_running()
|
||||
uint any_slave_sql_running(bool already_locked)
|
||||
{
|
||||
uint count= 0;
|
||||
HASH *hash;
|
||||
DBUG_ENTER("any_slave_sql_running");
|
||||
|
||||
mysql_mutex_lock(&LOCK_active_mi);
|
||||
if (!already_locked)
|
||||
mysql_mutex_lock(&LOCK_active_mi);
|
||||
if (unlikely(shutdown_in_progress || !master_info_index))
|
||||
count= 1;
|
||||
else
|
||||
{
|
||||
hash= &master_info_index->master_info_hash;
|
||||
for (uint i= 0; i< hash->records; ++i)
|
||||
{
|
||||
Master_info *mi= (Master_info *)my_hash_element(hash, i);
|
||||
if (mi->rli.slave_running != MYSQL_SLAVE_NOT_RUN)
|
||||
count++;
|
||||
}
|
||||
}
|
||||
if (!already_locked)
|
||||
mysql_mutex_unlock(&LOCK_active_mi);
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
hash= &master_info_index->master_info_hash;
|
||||
for (uint i= 0; i< hash->records; ++i)
|
||||
{
|
||||
Master_info *mi= (Master_info *)my_hash_element(hash, i);
|
||||
if (mi->rli.slave_running != MYSQL_SLAVE_NOT_RUN)
|
||||
count++;
|
||||
}
|
||||
mysql_mutex_unlock(&LOCK_active_mi);
|
||||
DBUG_RETURN(count);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user