Simplified THD::current_linfo locking
LOG_INFO::lock was useless. It could've only protect against concurrent iterators execution, which was already protected by LOCK_thread_count. Use LOCK_thd_data instead of LOCK_thread_count as a protection against THD::current_linfo reset. Aim is to reduce usage of LOCK_thread_count and COND_thread_count. Part of MDEV-15135.
This commit is contained in:
parent
c88fd54d17
commit
891be49a36
@ -25,7 +25,6 @@ WHERE name IN (
|
||||
AND enabled = 'yes' AND timed = 'yes'
|
||||
ORDER BY name;
|
||||
NAME ENABLED TIMED
|
||||
wait/synch/mutex/sql/LOG_INFO::lock YES YES
|
||||
wait/synch/mutex/sql/THD::LOCK_thd_data YES YES
|
||||
SELECT * FROM performance_schema.setup_instruments
|
||||
WHERE name = 'wait/synch/mutex/sql/hash_filo::lock'
|
||||
|
12
sql/log.h
12
sql/log.h
@ -247,10 +247,6 @@ extern TC_LOG_DUMMY tc_log_dummy;
|
||||
|
||||
class Relay_log_info;
|
||||
|
||||
#ifdef HAVE_PSI_INTERFACE
|
||||
extern PSI_mutex_key key_LOG_INFO_lock;
|
||||
#endif
|
||||
|
||||
/*
|
||||
Note that we destroy the lock mutex in the desctructor here.
|
||||
This means that object instances cannot be destroyed/go out of scope,
|
||||
@ -262,19 +258,11 @@ typedef struct st_log_info
|
||||
my_off_t index_file_offset, index_file_start_offset;
|
||||
my_off_t pos;
|
||||
bool fatal; // if the purge happens to give us a negative offset
|
||||
mysql_mutex_t lock;
|
||||
st_log_info() : index_file_offset(0), index_file_start_offset(0),
|
||||
pos(0), fatal(0)
|
||||
{
|
||||
DBUG_ENTER("LOG_INFO");
|
||||
log_file_name[0] = '\0';
|
||||
mysql_mutex_init(key_LOG_INFO_lock, &lock, MY_MUTEX_INIT_FAST);
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
~st_log_info()
|
||||
{
|
||||
DBUG_ENTER("~LOG_INFO");
|
||||
mysql_mutex_destroy(&lock);
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
} LOG_INFO;
|
||||
|
@ -908,7 +908,7 @@ PSI_mutex_key key_BINLOG_LOCK_index, key_BINLOG_LOCK_xid_list,
|
||||
key_rpl_group_info_sleep_lock,
|
||||
key_relay_log_info_log_space_lock, key_relay_log_info_run_lock,
|
||||
key_structure_guard_mutex, key_TABLE_SHARE_LOCK_ha_data,
|
||||
key_LOCK_error_messages, key_LOG_INFO_lock,
|
||||
key_LOCK_error_messages,
|
||||
key_LOCK_start_thread,
|
||||
key_LOCK_thread_count, key_LOCK_thread_cache,
|
||||
key_PARTITION_LOCK_auto_inc;
|
||||
@ -1003,7 +1003,6 @@ static PSI_mutex_info all_server_mutexes[]=
|
||||
{ &key_LOCK_after_binlog_sync, "LOCK_after_binlog_sync", PSI_FLAG_GLOBAL},
|
||||
{ &key_LOCK_commit_ordered, "LOCK_commit_ordered", PSI_FLAG_GLOBAL},
|
||||
{ &key_LOCK_slave_background, "LOCK_slave_background", PSI_FLAG_GLOBAL},
|
||||
{ &key_LOG_INFO_lock, "LOG_INFO::lock", 0},
|
||||
{ &key_LOCK_thread_count, "LOCK_thread_count", PSI_FLAG_GLOBAL},
|
||||
{ &key_LOCK_thread_cache, "LOCK_thread_cache", PSI_FLAG_GLOBAL},
|
||||
{ &key_PARTITION_LOCK_auto_inc, "HA_DATA_PARTITION::LOCK_auto_inc", 0},
|
||||
|
@ -4934,15 +4934,15 @@ public:
|
||||
}
|
||||
/*
|
||||
Reset current_linfo
|
||||
Setting current_linfo to 0 needs to be done with LOCK_thread_count to
|
||||
Setting current_linfo to 0 needs to be done with LOCK_thd_data to
|
||||
ensure that adjust_linfo_offsets doesn't use a structure that may
|
||||
be deleted.
|
||||
*/
|
||||
inline void reset_current_linfo()
|
||||
{
|
||||
mysql_mutex_lock(&LOCK_thread_count);
|
||||
mysql_mutex_lock(&LOCK_thd_data);
|
||||
current_linfo= 0;
|
||||
mysql_mutex_unlock(&LOCK_thread_count);
|
||||
mysql_mutex_unlock(&LOCK_thd_data);
|
||||
}
|
||||
|
||||
|
||||
|
@ -537,9 +537,9 @@ void adjust_linfo_offsets(my_off_t purge_offset)
|
||||
while ((tmp=it++))
|
||||
{
|
||||
LOG_INFO* linfo;
|
||||
mysql_mutex_lock(&tmp->LOCK_thd_data);
|
||||
if ((linfo = tmp->current_linfo))
|
||||
{
|
||||
mysql_mutex_lock(&linfo->lock);
|
||||
/*
|
||||
Index file offset can be less that purge offset only if
|
||||
we just started reading the index file. In that case
|
||||
@ -549,8 +549,8 @@ void adjust_linfo_offsets(my_off_t purge_offset)
|
||||
linfo->fatal = (linfo->index_file_offset != 0);
|
||||
else
|
||||
linfo->index_file_offset -= purge_offset;
|
||||
mysql_mutex_unlock(&linfo->lock);
|
||||
}
|
||||
mysql_mutex_unlock(&tmp->LOCK_thd_data);
|
||||
}
|
||||
mysql_mutex_unlock(&LOCK_thread_count);
|
||||
}
|
||||
@ -568,14 +568,12 @@ bool log_in_use(const char* log_name)
|
||||
while ((tmp=it++))
|
||||
{
|
||||
LOG_INFO* linfo;
|
||||
mysql_mutex_lock(&tmp->LOCK_thd_data);
|
||||
if ((linfo = tmp->current_linfo))
|
||||
{
|
||||
mysql_mutex_lock(&linfo->lock);
|
||||
result = !memcmp(log_name, linfo->log_file_name, log_name_len);
|
||||
mysql_mutex_unlock(&linfo->lock);
|
||||
if (result)
|
||||
break;
|
||||
}
|
||||
mysql_mutex_unlock(&tmp->LOCK_thd_data);
|
||||
if (result)
|
||||
break;
|
||||
}
|
||||
|
||||
mysql_mutex_unlock(&LOCK_thread_count);
|
||||
|
Loading…
x
Reference in New Issue
Block a user