Commit 891be49a authored by Sergey Vojtovich's avatar Sergey Vojtovich

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.
parent c88fd54d
...@@ -25,7 +25,6 @@ WHERE name IN ( ...@@ -25,7 +25,6 @@ WHERE name IN (
AND enabled = 'yes' AND timed = 'yes' AND enabled = 'yes' AND timed = 'yes'
ORDER BY name; ORDER BY name;
NAME ENABLED TIMED NAME ENABLED TIMED
wait/synch/mutex/sql/LOG_INFO::lock YES YES
wait/synch/mutex/sql/THD::LOCK_thd_data YES YES wait/synch/mutex/sql/THD::LOCK_thd_data YES YES
SELECT * FROM performance_schema.setup_instruments SELECT * FROM performance_schema.setup_instruments
WHERE name = 'wait/synch/mutex/sql/hash_filo::lock' WHERE name = 'wait/synch/mutex/sql/hash_filo::lock'
......
...@@ -247,10 +247,6 @@ extern TC_LOG_DUMMY tc_log_dummy; ...@@ -247,10 +247,6 @@ extern TC_LOG_DUMMY tc_log_dummy;
class Relay_log_info; 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. Note that we destroy the lock mutex in the desctructor here.
This means that object instances cannot be destroyed/go out of scope, This means that object instances cannot be destroyed/go out of scope,
...@@ -262,19 +258,11 @@ typedef struct st_log_info ...@@ -262,19 +258,11 @@ typedef struct st_log_info
my_off_t index_file_offset, index_file_start_offset; my_off_t index_file_offset, index_file_start_offset;
my_off_t pos; my_off_t pos;
bool fatal; // if the purge happens to give us a negative offset 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), st_log_info() : index_file_offset(0), index_file_start_offset(0),
pos(0), fatal(0) pos(0), fatal(0)
{ {
DBUG_ENTER("LOG_INFO"); DBUG_ENTER("LOG_INFO");
log_file_name[0] = '\0'; 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; DBUG_VOID_RETURN;
} }
} LOG_INFO; } LOG_INFO;
......
...@@ -908,7 +908,7 @@ PSI_mutex_key key_BINLOG_LOCK_index, key_BINLOG_LOCK_xid_list, ...@@ -908,7 +908,7 @@ PSI_mutex_key key_BINLOG_LOCK_index, key_BINLOG_LOCK_xid_list,
key_rpl_group_info_sleep_lock, key_rpl_group_info_sleep_lock,
key_relay_log_info_log_space_lock, key_relay_log_info_run_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_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_start_thread,
key_LOCK_thread_count, key_LOCK_thread_cache, key_LOCK_thread_count, key_LOCK_thread_cache,
key_PARTITION_LOCK_auto_inc; key_PARTITION_LOCK_auto_inc;
...@@ -1003,7 +1003,6 @@ static PSI_mutex_info all_server_mutexes[]= ...@@ -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_after_binlog_sync, "LOCK_after_binlog_sync", PSI_FLAG_GLOBAL},
{ &key_LOCK_commit_ordered, "LOCK_commit_ordered", PSI_FLAG_GLOBAL}, { &key_LOCK_commit_ordered, "LOCK_commit_ordered", PSI_FLAG_GLOBAL},
{ &key_LOCK_slave_background, "LOCK_slave_background", 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_count, "LOCK_thread_count", PSI_FLAG_GLOBAL},
{ &key_LOCK_thread_cache, "LOCK_thread_cache", 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}, { &key_PARTITION_LOCK_auto_inc, "HA_DATA_PARTITION::LOCK_auto_inc", 0},
......
...@@ -4934,15 +4934,15 @@ class THD :public Statement, ...@@ -4934,15 +4934,15 @@ class THD :public Statement,
} }
/* /*
Reset current_linfo 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 ensure that adjust_linfo_offsets doesn't use a structure that may
be deleted. be deleted.
*/ */
inline void reset_current_linfo() inline void reset_current_linfo()
{ {
mysql_mutex_lock(&LOCK_thread_count); mysql_mutex_lock(&LOCK_thd_data);
current_linfo= 0; 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) ...@@ -537,9 +537,9 @@ void adjust_linfo_offsets(my_off_t purge_offset)
while ((tmp=it++)) while ((tmp=it++))
{ {
LOG_INFO* linfo; LOG_INFO* linfo;
mysql_mutex_lock(&tmp->LOCK_thd_data);
if ((linfo = tmp->current_linfo)) if ((linfo = tmp->current_linfo))
{ {
mysql_mutex_lock(&linfo->lock);
/* /*
Index file offset can be less that purge offset only if Index file offset can be less that purge offset only if
we just started reading the index file. In that case we just started reading the index file. In that case
...@@ -549,8 +549,8 @@ void adjust_linfo_offsets(my_off_t purge_offset) ...@@ -549,8 +549,8 @@ void adjust_linfo_offsets(my_off_t purge_offset)
linfo->fatal = (linfo->index_file_offset != 0); linfo->fatal = (linfo->index_file_offset != 0);
else else
linfo->index_file_offset -= purge_offset; linfo->index_file_offset -= purge_offset;
mysql_mutex_unlock(&linfo->lock);
} }
mysql_mutex_unlock(&tmp->LOCK_thd_data);
} }
mysql_mutex_unlock(&LOCK_thread_count); mysql_mutex_unlock(&LOCK_thread_count);
} }
...@@ -568,15 +568,13 @@ bool log_in_use(const char* log_name) ...@@ -568,15 +568,13 @@ bool log_in_use(const char* log_name)
while ((tmp=it++)) while ((tmp=it++))
{ {
LOG_INFO* linfo; LOG_INFO* linfo;
mysql_mutex_lock(&tmp->LOCK_thd_data);
if ((linfo = tmp->current_linfo)) if ((linfo = tmp->current_linfo))
{
mysql_mutex_lock(&linfo->lock);
result = !memcmp(log_name, linfo->log_file_name, log_name_len); result = !memcmp(log_name, linfo->log_file_name, log_name_len);
mysql_mutex_unlock(&linfo->lock); mysql_mutex_unlock(&tmp->LOCK_thd_data);
if (result) if (result)
break; break;
} }
}
mysql_mutex_unlock(&LOCK_thread_count); mysql_mutex_unlock(&LOCK_thread_count);
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