mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 12:02:42 +01:00
Don't use LOCK_status for the duration of SHOW STATUS because of possible lookups.
Instead we use LOCK_status only to protect summary of thread statistics and use a new mutex, LOCK_show_status to protect concurrent SHOW STATUS. sql/mysqld.cc: Add LOCK_show_status Don't free LOCK_status while calculating status variables. sql/mysqld.h: Add LOCK_show_status sql/sql_show.cc: Use LOCK_show_status to protect SHOW STATUS instead of LOCK_status.
This commit is contained in:
parent
9276e0e911
commit
e36d6f03a4
3 changed files with 19 additions and 13 deletions
|
@ -703,7 +703,7 @@ pthread_key(MEM_ROOT**,THR_MALLOC);
|
|||
pthread_key(THD*, THR_THD);
|
||||
mysql_mutex_t LOCK_thread_count, LOCK_thread_cache;
|
||||
mysql_mutex_t
|
||||
LOCK_status, LOCK_error_log, LOCK_short_uuid_generator,
|
||||
LOCK_status, LOCK_show_status, LOCK_error_log, LOCK_short_uuid_generator,
|
||||
LOCK_delayed_insert, LOCK_delayed_status, LOCK_delayed_create,
|
||||
LOCK_crypt,
|
||||
LOCK_global_system_variables,
|
||||
|
@ -860,7 +860,8 @@ PSI_mutex_key key_BINLOG_LOCK_index, key_BINLOG_LOCK_xid_list,
|
|||
key_LOCK_gdl, key_LOCK_global_system_variables,
|
||||
key_LOCK_manager,
|
||||
key_LOCK_prepared_stmt_count,
|
||||
key_LOCK_rpl_status, key_LOCK_server_started, key_LOCK_status,
|
||||
key_LOCK_rpl_status, key_LOCK_server_started,
|
||||
key_LOCK_status, key_LOCK_show_status,
|
||||
key_LOCK_system_variables_hash, key_LOCK_thd_data,
|
||||
key_LOCK_user_conn, key_LOCK_uuid_short_generator, key_LOG_LOCK_log,
|
||||
key_master_info_data_lock, key_master_info_run_lock,
|
||||
|
@ -920,6 +921,7 @@ 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},
|
||||
|
@ -2136,6 +2138,7 @@ static void clean_up_mutexes()
|
|||
mysql_mutex_destroy(&LOCK_thread_count);
|
||||
mysql_mutex_destroy(&LOCK_thread_cache);
|
||||
mysql_mutex_destroy(&LOCK_status);
|
||||
mysql_mutex_destroy(&LOCK_show_status);
|
||||
mysql_mutex_destroy(&LOCK_delayed_insert);
|
||||
mysql_mutex_destroy(&LOCK_delayed_status);
|
||||
mysql_mutex_destroy(&LOCK_delayed_create);
|
||||
|
@ -4376,6 +4379,7 @@ static int init_thread_environment()
|
|||
mysql_mutex_init(key_LOCK_thread_count, &LOCK_thread_count, MY_MUTEX_INIT_FAST);
|
||||
mysql_mutex_init(key_LOCK_thread_cache, &LOCK_thread_cache, 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,
|
||||
|
@ -6238,7 +6242,8 @@ void handle_connections_sockets()
|
|||
(void) mysql_socket_close(new_sock);
|
||||
/*
|
||||
The connection was refused by TCP wrappers.
|
||||
There are no details (by client IP) available to update the host_cache.
|
||||
There are no details (by client IP) available to update the
|
||||
host_cache.
|
||||
*/
|
||||
statistic_increment(connection_errors_tcpwrap, &LOCK_status);
|
||||
continue;
|
||||
|
@ -7232,7 +7237,6 @@ static int show_slave_running(THD *thd, SHOW_VAR *var, char *buff)
|
|||
|
||||
var->type= SHOW_MY_BOOL;
|
||||
var->value= buff;
|
||||
mysql_mutex_unlock(&LOCK_status);
|
||||
mysql_mutex_lock(&LOCK_active_mi);
|
||||
if (master_info_index)
|
||||
{
|
||||
|
@ -7244,7 +7248,6 @@ static int show_slave_running(THD *thd, SHOW_VAR *var, char *buff)
|
|||
mi->rli.slave_running);
|
||||
}
|
||||
mysql_mutex_unlock(&LOCK_active_mi);
|
||||
mysql_mutex_lock(&LOCK_status);
|
||||
if (mi)
|
||||
*((my_bool *)buff)= tmp;
|
||||
else
|
||||
|
@ -7261,7 +7264,6 @@ static int show_slave_received_heartbeats(THD *thd, SHOW_VAR *var, char *buff)
|
|||
|
||||
var->type= SHOW_LONGLONG;
|
||||
var->value= buff;
|
||||
mysql_mutex_unlock(&LOCK_status);
|
||||
mysql_mutex_lock(&LOCK_active_mi);
|
||||
if (master_info_index)
|
||||
{
|
||||
|
@ -7272,7 +7274,6 @@ static int show_slave_received_heartbeats(THD *thd, SHOW_VAR *var, char *buff)
|
|||
tmp= mi->received_heartbeats;
|
||||
}
|
||||
mysql_mutex_unlock(&LOCK_active_mi);
|
||||
mysql_mutex_lock(&LOCK_status);
|
||||
if (mi)
|
||||
*((longlong *)buff)= tmp;
|
||||
else
|
||||
|
@ -7289,7 +7290,6 @@ static int show_heartbeat_period(THD *thd, SHOW_VAR *var, char *buff)
|
|||
|
||||
var->type= SHOW_CHAR;
|
||||
var->value= buff;
|
||||
mysql_mutex_unlock(&LOCK_status);
|
||||
mysql_mutex_lock(&LOCK_active_mi);
|
||||
if (master_info_index)
|
||||
{
|
||||
|
@ -7300,7 +7300,6 @@ static int show_heartbeat_period(THD *thd, SHOW_VAR *var, char *buff)
|
|||
tmp= mi->heartbeat_period;
|
||||
}
|
||||
mysql_mutex_unlock(&LOCK_active_mi);
|
||||
mysql_mutex_lock(&LOCK_status);
|
||||
if (mi)
|
||||
sprintf(buff, "%.3f", tmp);
|
||||
else
|
||||
|
|
|
@ -257,7 +257,8 @@ extern PSI_mutex_key key_BINLOG_LOCK_index, key_BINLOG_LOCK_xid_list,
|
|||
key_LOCK_gdl, key_LOCK_global_system_variables,
|
||||
key_LOCK_logger, key_LOCK_manager,
|
||||
key_LOCK_prepared_stmt_count,
|
||||
key_LOCK_rpl_status, key_LOCK_server_started, key_LOCK_status,
|
||||
key_LOCK_rpl_status, key_LOCK_server_started,
|
||||
key_LOCK_status, key_LOCK_show_status,
|
||||
key_LOCK_thd_data,
|
||||
key_LOCK_user_conn, key_LOG_LOCK_log,
|
||||
key_master_info_data_lock, key_master_info_run_lock,
|
||||
|
@ -513,7 +514,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_item_func_sleep, LOCK_status, LOCK_show_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,
|
||||
|
|
|
@ -7342,14 +7342,20 @@ int fill_status(THD *thd, TABLE_LIST *tables, COND *cond)
|
|||
if (partial_cond)
|
||||
partial_cond->val_int();
|
||||
|
||||
mysql_mutex_lock(&LOCK_status);
|
||||
if (option_type == 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);
|
||||
res= show_status_array(thd, wild,
|
||||
(SHOW_VAR *)all_status_vars.buffer,
|
||||
option_type, tmp1, "", tables->table,
|
||||
upper_case_names, partial_cond);
|
||||
mysql_mutex_unlock(&LOCK_status);
|
||||
mysql_mutex_unlock(&LOCK_show_status);
|
||||
DBUG_RETURN(res);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue