diff options
author | Vladislav Vaintroub <wlad@mariadb.com> | 2019-01-24 19:26:34 +0100 |
---|---|---|
committer | Sergey Vojtovich <svoj@mariadb.org> | 2019-01-28 17:49:53 +0400 |
commit | c2318291be7458238729ed80233ea71f1e6a62b8 (patch) | |
tree | 81adfc496da27bfff0d760a07ca7833e2f8e9832 /sql | |
parent | 8b4fcc434d5e5afdac3068c9ef041e75f4255e79 (diff) | |
download | mariadb-git-c2318291be7458238729ed80233ea71f1e6a62b8.tar.gz |
MDEV-15135 - Make LOCK_show_status rwlock, to enable parallelism of
fill_status.
Also, remove LOCK_status around calc_sum_of_all_status()
Also, rename LOCK_show_status into LOCK_all_status_vars.
This reflects the variable the lock protects.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/log.cc | 2 | ||||
-rw-r--r-- | sql/mysqld.cc | 17 | ||||
-rw-r--r-- | sql/mysqld.h | 5 | ||||
-rw-r--r-- | sql/sql_show.cc | 15 |
4 files changed, 19 insertions, 20 deletions
diff --git a/sql/log.cc b/sql/log.cc index 3857bb55340..a4a2b4b1e37 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -10486,7 +10486,7 @@ set_binlog_snapshot_file(const char *src) Copy out current values of status variables, for SHOW STATUS or information_schema.global_status. - This is called only under LOCK_show_status, so we can fill in a static array. + This is called only under LOCK_all_status_vars, so we can fill in a static array. */ void TC_LOG_BINLOG::set_status_variables(THD *thd) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index a836c3946db..97e2cc1fc8e 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -709,13 +709,12 @@ mysql_mutex_t LOCK_start_thread; mysql_mutex_t LOCK_thread_cache; mysql_mutex_t - LOCK_status, LOCK_show_status, LOCK_error_log, LOCK_short_uuid_generator, + LOCK_status, LOCK_error_log, LOCK_short_uuid_generator, LOCK_delayed_insert, LOCK_delayed_status, LOCK_delayed_create, LOCK_crypt, LOCK_global_system_variables, LOCK_user_conn, LOCK_slave_list, LOCK_connection_count, LOCK_error_messages, LOCK_slave_background; - mysql_mutex_t LOCK_stats, LOCK_global_user_client_stats, LOCK_global_table_stats, LOCK_global_index_stats; @@ -738,6 +737,7 @@ mysql_mutex_t LOCK_des_key_file; #endif mysql_rwlock_t LOCK_grant, LOCK_sys_init_connect, LOCK_sys_init_slave; mysql_rwlock_t LOCK_ssl_refresh; +mysql_rwlock_t LOCK_all_status_vars; mysql_prlock_t LOCK_system_variables_hash; mysql_cond_t COND_thread_count, COND_start_thread; pthread_t signal_thread; @@ -879,7 +879,7 @@ PSI_mutex_key key_BINLOG_LOCK_index, key_BINLOG_LOCK_xid_list, key_LOCK_manager, key_LOCK_prepared_stmt_count, key_LOCK_rpl_status, key_LOCK_server_started, - key_LOCK_status, key_LOCK_show_status, + key_LOCK_status, key_LOCK_system_variables_hash, key_LOCK_thd_data, key_LOCK_thd_kill, key_LOCK_user_conn, key_LOCK_uuid_short_generator, key_LOG_LOCK_log, key_master_info_data_lock, key_master_info_run_lock, @@ -951,7 +951,6 @@ static PSI_mutex_info all_server_mutexes[]= { &key_LOCK_rpl_status, "LOCK_rpl_status", PSI_FLAG_GLOBAL}, { &key_LOCK_server_started, "LOCK_server_started", PSI_FLAG_GLOBAL}, { &key_LOCK_status, "LOCK_status", PSI_FLAG_GLOBAL}, - { &key_LOCK_show_status, "LOCK_show_status", PSI_FLAG_GLOBAL}, { &key_LOCK_system_variables_hash, "LOCK_system_variables_hash", PSI_FLAG_GLOBAL}, { &key_LOCK_stats, "LOCK_stats", PSI_FLAG_GLOBAL}, { &key_LOCK_global_user_client_stats, "LOCK_global_user_client_stats", PSI_FLAG_GLOBAL}, @@ -1002,7 +1001,8 @@ PSI_rwlock_key key_rwlock_LOCK_grant, key_rwlock_LOCK_logger, key_LOCK_SEQUENCE, key_rwlock_LOCK_vers_stats, key_rwlock_LOCK_stat_serial, key_rwlock_LOCK_ssl_refresh, - key_rwlock_THD_list; + key_rwlock_THD_list, + key_rwlock_LOCK_all_status_vars; static PSI_rwlock_info all_server_rwlocks[]= { @@ -1019,7 +1019,8 @@ static PSI_rwlock_info all_server_rwlocks[]= { &key_rwlock_LOCK_vers_stats, "Vers_field_stats::lock", 0}, { &key_rwlock_LOCK_stat_serial, "TABLE_SHARE::LOCK_stat_serial", 0}, { &key_rwlock_LOCK_ssl_refresh, "LOCK_ssl_refresh", PSI_FLAG_GLOBAL }, - { &key_rwlock_THD_list, "THD_list::lock", PSI_FLAG_GLOBAL } + { &key_rwlock_THD_list, "THD_list::lock", PSI_FLAG_GLOBAL }, + { &key_rwlock_LOCK_all_status_vars, "LOCK_all_status_vars", PSI_FLAG_GLOBAL } }; #ifdef HAVE_MMAP @@ -2230,7 +2231,7 @@ static void clean_up_mutexes() mysql_mutex_destroy(&LOCK_thread_cache); mysql_mutex_destroy(&LOCK_start_thread); mysql_mutex_destroy(&LOCK_status); - mysql_mutex_destroy(&LOCK_show_status); + mysql_rwlock_destroy(&LOCK_all_status_vars); mysql_mutex_destroy(&LOCK_delayed_insert); mysql_mutex_destroy(&LOCK_delayed_status); mysql_mutex_destroy(&LOCK_delayed_create); @@ -4584,7 +4585,6 @@ static int init_thread_environment() mysql_mutex_init(key_LOCK_thread_cache, &LOCK_thread_cache, MY_MUTEX_INIT_FAST); mysql_mutex_init(key_LOCK_start_thread, &LOCK_start_thread, MY_MUTEX_INIT_FAST); mysql_mutex_init(key_LOCK_status, &LOCK_status, MY_MUTEX_INIT_FAST); - mysql_mutex_init(key_LOCK_show_status, &LOCK_show_status, MY_MUTEX_INIT_SLOW); mysql_mutex_init(key_LOCK_delayed_insert, &LOCK_delayed_insert, MY_MUTEX_INIT_FAST); mysql_mutex_init(key_LOCK_delayed_status, @@ -4647,6 +4647,7 @@ static int init_thread_environment() mysql_rwlock_init(key_rwlock_LOCK_ssl_refresh, &LOCK_ssl_refresh); mysql_rwlock_init(key_rwlock_LOCK_grant, &LOCK_grant); mysql_cond_init(key_COND_thread_count, &COND_thread_count, NULL); + mysql_rwlock_init(key_rwlock_LOCK_all_status_vars, &LOCK_all_status_vars); mysql_cond_init(key_COND_thread_cache, &COND_thread_cache, NULL); mysql_cond_init(key_COND_start_thread, &COND_start_thread, NULL); mysql_cond_init(key_COND_flush_thread_cache, &COND_flush_thread_cache, NULL); diff --git a/sql/mysqld.h b/sql/mysqld.h index 33eee98afeb..32c29722d25 100644 --- a/sql/mysqld.h +++ b/sql/mysqld.h @@ -334,7 +334,7 @@ extern PSI_mutex_key key_BINLOG_LOCK_index, key_BINLOG_LOCK_xid_list, key_LOCK_logger, key_LOCK_manager, key_LOCK_prepared_stmt_count, key_LOCK_rpl_status, key_LOCK_server_started, - key_LOCK_status, key_LOCK_show_status, + key_LOCK_status, key_LOCK_thd_data, key_LOCK_thd_kill, key_LOCK_user_conn, key_LOG_LOCK_log, key_master_info_data_lock, key_master_info_run_lock, @@ -620,7 +620,7 @@ extern MYSQL_PLUGIN_IMPORT key_map key_map_full; /* Should be threaded Server mutex locks and condition variables. */ extern mysql_mutex_t - LOCK_item_func_sleep, LOCK_status, LOCK_show_status, + LOCK_item_func_sleep, LOCK_status, LOCK_error_log, LOCK_delayed_insert, LOCK_short_uuid_generator, LOCK_delayed_status, LOCK_delayed_create, LOCK_crypt, LOCK_timezone, LOCK_slave_list, LOCK_active_mi, LOCK_manager, @@ -628,6 +628,7 @@ extern mysql_mutex_t LOCK_prepared_stmt_count, LOCK_error_messages, LOCK_connection_count, LOCK_slave_background; extern MYSQL_PLUGIN_IMPORT mysql_mutex_t LOCK_thread_count; +extern mysql_rwlock_t LOCK_all_status_vars; extern mysql_mutex_t LOCK_start_thread; #ifdef HAVE_OPENSSL extern char* des_key_file; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 70905bcb2e7..3d2723081a3 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -3383,7 +3383,7 @@ int add_status_vars(SHOW_VAR *list) { int res= 0; if (status_vars_inited) - mysql_mutex_lock(&LOCK_show_status); + mysql_rwlock_wrlock(&LOCK_all_status_vars); if (!all_status_vars.buffer && // array is not allocated yet - do it now my_init_dynamic_array(&all_status_vars, sizeof(SHOW_VAR), 250, 50, MYF(0))) { @@ -3398,7 +3398,7 @@ int add_status_vars(SHOW_VAR *list) sort_dynamic(&all_status_vars, show_var_cmp); err: if (status_vars_inited) - mysql_mutex_unlock(&LOCK_show_status); + mysql_rwlock_unlock(&LOCK_all_status_vars); return res; } @@ -3460,7 +3460,7 @@ void remove_status_vars(SHOW_VAR *list) { if (status_vars_inited) { - mysql_mutex_lock(&LOCK_show_status); + mysql_rwlock_wrlock(&LOCK_all_status_vars); SHOW_VAR *all= dynamic_element(&all_status_vars, 0, SHOW_VAR *); for (; list->name; list++) @@ -3481,7 +3481,7 @@ void remove_status_vars(SHOW_VAR *list) } } shrink_var_array(&all_status_vars); - mysql_mutex_unlock(&LOCK_show_status); + mysql_rwlock_unlock(&LOCK_all_status_vars); } else { @@ -7836,18 +7836,15 @@ int fill_status(THD *thd, TABLE_LIST *tables, COND *cond) if (scope == OPT_GLOBAL) { - /* We only hold LOCK_status for summary status vars */ - mysql_mutex_lock(&LOCK_status); calc_sum_of_all_status(&tmp); - mysql_mutex_unlock(&LOCK_status); } - mysql_mutex_lock(&LOCK_show_status); + mysql_rwlock_rdlock(&LOCK_all_status_vars); res= show_status_array(thd, wild, (SHOW_VAR *)all_status_vars.buffer, scope, tmp1, "", tables->table, upper_case_names, partial_cond); - mysql_mutex_unlock(&LOCK_show_status); + mysql_rwlock_unlock(&LOCK_all_status_vars); DBUG_RETURN(res); } |