mirror of
https://github.com/MariaDB/server.git
synced 2025-08-07 00:04:31 +03:00
Fix for MDEV-8301; Statistics for a thread could be counted twice in SHOW STATUS while thread was ending
Fixed by adding a marker if we have added the thread statistics to the global counters.
This commit is contained in:
@@ -1263,6 +1263,7 @@ void THD::init(void)
|
|||||||
bzero((char *) &status_var, sizeof(status_var));
|
bzero((char *) &status_var, sizeof(status_var));
|
||||||
bzero((char *) &org_status_var, sizeof(org_status_var));
|
bzero((char *) &org_status_var, sizeof(org_status_var));
|
||||||
start_bytes_received= 0;
|
start_bytes_received= 0;
|
||||||
|
status_in_global= 0;
|
||||||
|
|
||||||
if (variables.sql_log_bin)
|
if (variables.sql_log_bin)
|
||||||
variables.option_bits|= OPTION_BIN_LOG;
|
variables.option_bits|= OPTION_BIN_LOG;
|
||||||
@@ -1366,6 +1367,7 @@ void THD::change_user(void)
|
|||||||
cleanup();
|
cleanup();
|
||||||
reset_killed();
|
reset_killed();
|
||||||
cleanup_done= 0;
|
cleanup_done= 0;
|
||||||
|
status_in_global= 0;
|
||||||
init();
|
init();
|
||||||
stmt_map.reset();
|
stmt_map.reset();
|
||||||
my_hash_init(&user_vars, system_charset_info, USER_VARS_HASH_SIZE, 0, 0,
|
my_hash_init(&user_vars, system_charset_info, USER_VARS_HASH_SIZE, 0, 0,
|
||||||
|
@@ -1733,11 +1733,11 @@ public:
|
|||||||
/* Do not set socket timeouts for wait_timeout (used with threadpool) */
|
/* Do not set socket timeouts for wait_timeout (used with threadpool) */
|
||||||
bool skip_wait_timeout;
|
bool skip_wait_timeout;
|
||||||
|
|
||||||
/* container for handler's private per-connection data */
|
|
||||||
Ha_data ha_data[MAX_HA];
|
|
||||||
|
|
||||||
bool prepare_derived_at_open;
|
bool prepare_derived_at_open;
|
||||||
|
|
||||||
|
/* Set to 1 if status of this THD is already in global status */
|
||||||
|
bool status_in_global;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
To signal that the tmp table to be created is created for materialized
|
To signal that the tmp table to be created is created for materialized
|
||||||
derived table or a view.
|
derived table or a view.
|
||||||
@@ -1746,6 +1746,9 @@ public:
|
|||||||
|
|
||||||
bool save_prep_leaf_list;
|
bool save_prep_leaf_list;
|
||||||
|
|
||||||
|
/* container for handler's private per-connection data */
|
||||||
|
Ha_data ha_data[MAX_HA];
|
||||||
|
|
||||||
#ifndef MYSQL_CLIENT
|
#ifndef MYSQL_CLIENT
|
||||||
binlog_cache_mngr * binlog_setup_trx_data();
|
binlog_cache_mngr * binlog_setup_trx_data();
|
||||||
|
|
||||||
@@ -3116,6 +3119,8 @@ public:
|
|||||||
{
|
{
|
||||||
mysql_mutex_lock(&LOCK_status);
|
mysql_mutex_lock(&LOCK_status);
|
||||||
add_to_status(&global_status_var, &status_var);
|
add_to_status(&global_status_var, &status_var);
|
||||||
|
/* Mark that this THD status has already been added in global status */
|
||||||
|
status_in_global= 1;
|
||||||
mysql_mutex_unlock(&LOCK_status);
|
mysql_mutex_unlock(&LOCK_status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -3109,7 +3109,10 @@ void calc_sum_of_all_status(STATUS_VAR *to)
|
|||||||
|
|
||||||
/* Add to this status from existing threads */
|
/* Add to this status from existing threads */
|
||||||
while ((tmp= it++))
|
while ((tmp= it++))
|
||||||
add_to_status(to, &tmp->status_var);
|
{
|
||||||
|
if (!tmp->status_in_global)
|
||||||
|
add_to_status(to, &tmp->status_var);
|
||||||
|
}
|
||||||
|
|
||||||
mysql_mutex_unlock(&LOCK_thread_count);
|
mysql_mutex_unlock(&LOCK_thread_count);
|
||||||
DBUG_VOID_RETURN;
|
DBUG_VOID_RETURN;
|
||||||
|
Reference in New Issue
Block a user