diff options
author | Sergey Vojtovich <svoj@mariadb.org> | 2019-01-20 12:51:20 +0400 |
---|---|---|
committer | Sergey Vojtovich <svoj@mariadb.org> | 2019-01-28 17:39:07 +0400 |
commit | 891be49a36ebb951cd90d64d1b4c1cc633af1fdf (patch) | |
tree | 2388b9b4e75396e0423a2522eee02bd85d02097c | |
parent | c88fd54d171fdba6aad3f7e16a4060cca03143d3 (diff) | |
download | mariadb-git-891be49a36ebb951cd90d64d1b4c1cc633af1fdf.tar.gz |
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.
-rw-r--r-- | mysql-test/suite/perfschema/r/setup_instruments_defaults.result | 1 | ||||
-rw-r--r-- | sql/log.h | 12 | ||||
-rw-r--r-- | sql/mysqld.cc | 3 | ||||
-rw-r--r-- | sql/sql_class.h | 6 | ||||
-rw-r--r-- | sql/sql_repl.cc | 14 |
5 files changed, 10 insertions, 26 deletions
diff --git a/mysql-test/suite/perfschema/r/setup_instruments_defaults.result b/mysql-test/suite/perfschema/r/setup_instruments_defaults.result index f31bb1a8b7a..9ce90a2effa 100644 --- a/mysql-test/suite/perfschema/r/setup_instruments_defaults.result +++ b/mysql-test/suite/perfschema/r/setup_instruments_defaults.result @@ -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' diff --git a/sql/log.h b/sql/log.h index 42fcfcc3ab6..2d4cc7a74a1 100644 --- a/sql/log.h +++ b/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; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 8da5c299b74..f2065a55aed 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -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}, diff --git a/sql/sql_class.h b/sql/sql_class.h index 55eceda6c9f..6338eab9d45 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -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); } diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index 1847416368a..ab4a5c6a6b4 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -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); |