summaryrefslogtreecommitdiffstats
path: root/storage/perfschema
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 12:33:02 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 12:33:02 +0000
commit4fa488fb0159c629483b7994aa84e73926b132b9 (patch)
tree182a19db69cdcb92be54cc6a5b0b9bfab28f80fd /storage/perfschema
parentAdding debian version 1:10.11.6-2. (diff)
downloadmariadb-4fa488fb0159c629483b7994aa84e73926b132b9.tar.xz
mariadb-4fa488fb0159c629483b7994aa84e73926b132b9.zip
Merging upstream version 1:10.11.7.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'storage/perfschema')
-rw-r--r--storage/perfschema/CMakeLists.txt2
-rw-r--r--storage/perfschema/pfs_variable.cc97
-rw-r--r--storage/perfschema/pfs_variable.h8
-rw-r--r--storage/perfschema/pfs_visitor.cc3
-rw-r--r--storage/perfschema/table_helper.h2
-rw-r--r--storage/perfschema/unittest/CMakeLists.txt2
-rw-r--r--storage/perfschema/unittest/stub_pfs_global.h2
7 files changed, 58 insertions, 58 deletions
diff --git a/storage/perfschema/CMakeLists.txt b/storage/perfschema/CMakeLists.txt
index b4f5e96b..e703e43f 100644
--- a/storage/perfschema/CMakeLists.txt
+++ b/storage/perfschema/CMakeLists.txt
@@ -24,7 +24,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/sql
${CMAKE_BINARY_DIR}/sql
${CMAKE_CURRENT_BINARY_DIR}
- ${PCRE_INCLUDES}
+ ${PCRE_INCLUDE_DIRS}
${SSL_INCLUDE_DIRS})
ADD_DEFINITIONS(-DMYSQL_SERVER)
diff --git a/storage/perfschema/pfs_variable.cc b/storage/perfschema/pfs_variable.cc
index 239c55b6..a33fe2ed 100644
--- a/storage/perfschema/pfs_variable.cc
+++ b/storage/perfschema/pfs_variable.cc
@@ -66,7 +66,7 @@ static inline SHOW_SCOPE show_scope_from_type(enum enum_mysql_show_type type)
case SHOW_SIMPLE_FUNC:
case SHOW_UNDEF:
default:
- return SHOW_SCOPE_UNDEF;
+ return SHOW_SCOPE_ALL;
}
return SHOW_SCOPE_UNDEF;
}
@@ -254,7 +254,8 @@ int PFS_system_variable_cache::do_materialize_all(THD *unsafe_thd)
}
/* Release lock taken in get_THD(). */
- mysql_mutex_unlock(&m_safe_thd->LOCK_thd_data);
+ if (m_safe_thd != current_thd)
+ mysql_mutex_unlock(&m_safe_thd->LOCK_thd_kill);
m_materialized= true;
ret= 0;
@@ -354,7 +355,8 @@ int PFS_system_variable_cache::do_materialize_session(PFS_thread *pfs_thread)
}
/* Release lock taken in get_THD(). */
- mysql_mutex_unlock(&m_safe_thd->LOCK_thd_data);
+ if (m_safe_thd != current_thd)
+ mysql_mutex_unlock(&m_safe_thd->LOCK_thd_kill);
m_materialized= true;
ret= 0;
@@ -407,7 +409,8 @@ int PFS_system_variable_cache::do_materialize_session(PFS_thread *pfs_thread, ui
}
/* Release lock taken in get_THD(). */
- mysql_mutex_unlock(&m_safe_thd->LOCK_thd_data);
+ if (m_safe_thd != current_thd)
+ mysql_mutex_unlock(&m_safe_thd->LOCK_thd_kill);
m_materialized= true;
ret= 0;
@@ -458,7 +461,8 @@ int PFS_system_variable_cache::do_materialize_session(THD *unsafe_thd)
}
/* Release lock taken in get_THD(). */
- mysql_mutex_unlock(&m_safe_thd->LOCK_thd_data);
+ if (m_safe_thd != current_thd)
+ mysql_mutex_unlock(&m_safe_thd->LOCK_thd_kill);
m_materialized= true;
ret= 0;
@@ -716,6 +720,7 @@ bool PFS_status_variable_cache::can_aggregate(enum_mysql_show_type variable_type
case SHOW_CHAR_PTR:
case SHOW_ARRAY:
case SHOW_FUNC:
+ case SHOW_SIMPLE_FUNC:
case SHOW_INT:
case SHOW_LONG:
case SHOW_LONGLONG:
@@ -761,7 +766,7 @@ bool PFS_status_variable_cache::filter_show_var(const SHOW_VAR *show_var, bool s
/**
Build an array of SHOW_VARs from the global status array. Expand nested
subarrays, filter unwanted variables.
- NOTE: Must be done inside of LOCK_status to guard against plugin load/unload.
+ NOTE: Must be done under LOCK_all_status_vars
*/
bool PFS_status_variable_cache::init_show_var_array(enum_var_type scope, bool strict)
{
@@ -880,14 +885,12 @@ char * PFS_status_variable_cache::make_show_var_name(const char* prefix, const c
*/
bool PFS_status_variable_cache::do_initialize_session(void)
{
- /* Acquire LOCK_status to guard against plugin load/unload. */
- //if (m_current_thd->fill_status_recursion_level++ == 0)
- mysql_mutex_lock(&LOCK_status);
+ /* Acquire LOCK_all_status_vars to guard against plugin load/unload. */
+ mysql_rwlock_rdlock(&LOCK_all_status_vars);
bool ret= init_show_var_array(OPT_SESSION, true);
- //if (m_current_thd->fill_status_recursion_level-- == 1)
- mysql_mutex_unlock(&LOCK_status);
+ mysql_rwlock_unlock(&LOCK_all_status_vars);
return ret;
}
@@ -916,13 +919,12 @@ int PFS_status_variable_cache::do_materialize_global(void)
m_materialized= false;
DEBUG_SYNC(m_current_thd, "before_materialize_global_status_array");
- /* Acquire LOCK_status to guard against plugin load/unload. */
- //if (m_current_thd->fill_status_recursion_level++ == 0)
- mysql_mutex_lock(&LOCK_status);
+ /* Acquire LOCK_all_status_vars to guard against plugin load/unload. */
+ mysql_rwlock_rdlock(&LOCK_all_status_vars);
/*
- Build array of SHOW_VARs from global status array. Do this within
- LOCK_status to ensure that the array remains unchanged during
+ Build array of SHOW_VARs from global status array. Do this under
+ LOCK_all_status_vars to ensure that the array remains unchanged during
materialization.
*/
if (!m_external_init)
@@ -945,8 +947,7 @@ int PFS_status_variable_cache::do_materialize_global(void)
*/
manifest(m_current_thd, m_show_var_array.front(), &status_totals, "", false, true);
- //if (m_current_thd->fill_status_recursion_level-- == 1)
- mysql_mutex_unlock(&LOCK_status);
+ mysql_rwlock_unlock(&LOCK_all_status_vars);
m_materialized= true;
DEBUG_SYNC(m_current_thd, "after_materialize_global_status_array");
@@ -966,13 +967,11 @@ int PFS_status_variable_cache::do_materialize_all(THD* unsafe_thd)
m_materialized= false;
m_cache.clear();
- /* Avoid recursive acquisition of LOCK_status. */
- //if (m_current_thd->fill_status_recursion_level++ == 0)
- mysql_mutex_lock(&LOCK_status);
+ mysql_rwlock_rdlock(&LOCK_all_status_vars);
/*
- Build array of SHOW_VARs from global status array. Do this within
- LOCK_status to ensure that the array remains unchanged while this
+ Build array of SHOW_VARs from global status array. Do this under
+ LOCK_all_status_vars to ensure that the array remains unchanged while this
thread is materialized.
*/
if (!m_external_init)
@@ -989,14 +988,14 @@ int PFS_status_variable_cache::do_materialize_all(THD* unsafe_thd)
manifest(m_safe_thd, m_show_var_array.front(), status_vars, "", false, false);
/* Release lock taken in get_THD(). */
- mysql_mutex_unlock(&m_safe_thd->LOCK_thd_data);
+ if (m_safe_thd != current_thd)
+ mysql_mutex_unlock(&m_safe_thd->LOCK_thd_kill);
m_materialized= true;
ret= 0;
}
- //if (m_current_thd->fill_status_recursion_level-- == 1)
- mysql_mutex_unlock(&LOCK_status);
+ mysql_rwlock_unlock(&LOCK_all_status_vars);
return ret;
}
@@ -1012,13 +1011,11 @@ int PFS_status_variable_cache::do_materialize_session(THD* unsafe_thd)
m_materialized= false;
m_cache.clear();
- /* Avoid recursive acquisition of LOCK_status. */
- //if (m_current_thd->fill_status_recursion_level++ == 0)
- mysql_mutex_lock(&LOCK_status);
+ mysql_rwlock_rdlock(&LOCK_all_status_vars);
/*
- Build array of SHOW_VARs from global status array. Do this within
- LOCK_status to ensure that the array remains unchanged while this
+ Build array of SHOW_VARs from global status array. Do this under
+ LOCK_all_status_vars to ensure that the array remains unchanged while this
thread is materialized.
*/
if (!m_external_init)
@@ -1035,14 +1032,14 @@ int PFS_status_variable_cache::do_materialize_session(THD* unsafe_thd)
manifest(m_safe_thd, m_show_var_array.front(), status_vars, "", false, true);
/* Release lock taken in get_THD(). */
- mysql_mutex_unlock(&m_safe_thd->LOCK_thd_data);
+ if (m_safe_thd != current_thd)
+ mysql_mutex_unlock(&m_safe_thd->LOCK_thd_kill);
m_materialized= true;
ret= 0;
}
- //if (m_current_thd->fill_status_recursion_level-- == 1)
- mysql_mutex_unlock(&LOCK_status);
+ mysql_rwlock_unlock(&LOCK_all_status_vars);
return ret;
}
@@ -1059,9 +1056,8 @@ int PFS_status_variable_cache::do_materialize_session(PFS_thread *pfs_thread)
m_materialized= false;
m_cache.clear();
- /* Acquire LOCK_status to guard against plugin load/unload. */
- //if (m_current_thd->fill_status_recursion_level++ == 0)
- mysql_mutex_lock(&LOCK_status);
+ /* Acquire LOCK_all_status_vars to guard against plugin load/unload. */
+ mysql_rwlock_rdlock(&LOCK_all_status_vars);
/* The SHOW_VAR array must be initialized externally. */
assert(m_initialized);
@@ -1077,14 +1073,14 @@ int PFS_status_variable_cache::do_materialize_session(PFS_thread *pfs_thread)
manifest(m_safe_thd, m_show_var_array.front(), status_vars, "", false, true);
/* Release lock taken in get_THD(). */
- mysql_mutex_unlock(&m_safe_thd->LOCK_thd_data);
+ if (m_safe_thd != current_thd)
+ mysql_mutex_unlock(&m_safe_thd->LOCK_thd_kill);
m_materialized= true;
ret= 0;
}
- //if (m_current_thd->fill_status_recursion_level-- == 1)
- mysql_mutex_unlock(&LOCK_status);
+ mysql_rwlock_unlock(&LOCK_all_status_vars);
return ret;
}
@@ -1103,9 +1099,8 @@ int PFS_status_variable_cache::do_materialize_client(PFS_client *pfs_client)
m_materialized= false;
m_cache.clear();
- /* Acquire LOCK_status to guard against plugin load/unload. */
- //if (m_current_thd->fill_status_recursion_level++ == 0)
- mysql_mutex_lock(&LOCK_status);
+ /* Acquire LOCK_all_status_vars to guard against plugin load/unload. */
+ mysql_rwlock_rdlock(&LOCK_all_status_vars);
/* The SHOW_VAR array must be initialized externally. */
assert(m_initialized);
@@ -1122,8 +1117,7 @@ int PFS_status_variable_cache::do_materialize_client(PFS_client *pfs_client)
*/
manifest(m_current_thd, m_show_var_array.front(), &status_totals, "", false, true);
- //if (m_current_thd->fill_status_recursion_level-- == 1)
- mysql_mutex_unlock(&LOCK_status);
+ mysql_rwlock_unlock(&LOCK_all_status_vars);
m_materialized= true;
return 0;
@@ -1152,16 +1146,19 @@ void PFS_status_variable_cache::manifest(THD *thd, const SHOW_VAR *show_var_arra
reevaluate the new SHOW_TYPE and value. Handle nested case where
SHOW_FUNC resolves to another SHOW_FUNC.
*/
- if (show_var_ptr->type == SHOW_FUNC)
+ if (show_var_ptr->type == SHOW_FUNC || show_var_ptr->type == SHOW_SIMPLE_FUNC)
{
show_var_tmp= *show_var_ptr;
/*
Execute the function reference in show_var_tmp->value, which returns
show_var_tmp with a new type and new value.
*/
- for (const SHOW_VAR *var= show_var_ptr; var->type == SHOW_FUNC; var= &show_var_tmp)
+ for (const SHOW_VAR *var= show_var_ptr;
+ var->type == SHOW_FUNC || var->type == SHOW_SIMPLE_FUNC;
+ var= &show_var_tmp)
{
- ((mysql_show_var_func)(var->value))(thd, &show_var_tmp, value_buf.data, NULL, m_query_scope);
+ ((mysql_show_var_func)(var->value))(thd, &show_var_tmp, value_buf.data,
+ &thd->status_var, m_query_scope);
}
show_var_ptr= &show_var_tmp;
}
@@ -1213,7 +1210,7 @@ Status_variable::Status_variable(const SHOW_VAR *show_var, STATUS_VAR *status_va
/**
Resolve status value, convert to string.
show_var->value is an offset into status_vars.
- NOTE: Assumes LOCK_status is held.
+ NOTE: Assumes LOCK_all_status_vars is held.
*/
void Status_variable::init(const SHOW_VAR *show_var, STATUS_VAR *status_vars, enum_var_type query_scope)
{
@@ -1279,7 +1276,7 @@ void sum_account_status(PFS_client *pfs_account, STATUS_VAR *status_totals)
/**
Reset aggregated status counter stats for account, user and host.
- NOTE: Assumes LOCK_status is held.
+ NOTE: Assumes LOCK_all_status_vars is held.
*/
void reset_pfs_status_stats()
{
diff --git a/storage/perfschema/pfs_variable.h b/storage/perfschema/pfs_variable.h
index d3ad4c7f..7dc24826 100644
--- a/storage/perfschema/pfs_variable.h
+++ b/storage/perfschema/pfs_variable.h
@@ -211,8 +211,12 @@ public:
if (thd != m_unsafe_thd)
return false;
- /* Hold this lock to keep THD during materialization. */
- mysql_mutex_lock(&thd->LOCK_thd_data);
+ /*
+ Hold this lock to keep THD during materialization.
+ But don't lock current_thd (to be able to use set_killed() later
+ */
+ if (thd != current_thd)
+ mysql_mutex_lock(&thd->LOCK_thd_kill);
return true;
}
void set_unsafe_thd(THD *unsafe_thd) { m_unsafe_thd= unsafe_thd; }
diff --git a/storage/perfschema/pfs_visitor.cc b/storage/perfschema/pfs_visitor.cc
index 92a5c99e..7e3027ac 100644
--- a/storage/perfschema/pfs_visitor.cc
+++ b/storage/perfschema/pfs_visitor.cc
@@ -1356,8 +1356,7 @@ PFS_connection_status_visitor::~PFS_connection_status_visitor() = default;
/** Aggregate from global status. */
void PFS_connection_status_visitor::visit_global()
{
- /* NOTE: Requires lock on LOCK_status. */
- mysql_mutex_assert_owner(&LOCK_status);
+ /* NOTE: Requires lock on LOCK_all_status_vars. */
add_to_status(m_status_vars, &global_status_var);
}
diff --git a/storage/perfschema/table_helper.h b/storage/perfschema/table_helper.h
index ddea4c08..87572ef2 100644
--- a/storage/perfschema/table_helper.h
+++ b/storage/perfschema/table_helper.h
@@ -659,7 +659,7 @@ public:
private:
void make_row(const CHARSET_INFO *cs, const char* str, size_t length);
- char m_str[1024];
+ char m_str[2048];
uint m_length;
const CHARSET_INFO *m_charset;
};
diff --git a/storage/perfschema/unittest/CMakeLists.txt b/storage/perfschema/unittest/CMakeLists.txt
index 2a22990f..600795c7 100644
--- a/storage/perfschema/unittest/CMakeLists.txt
+++ b/storage/perfschema/unittest/CMakeLists.txt
@@ -22,7 +22,7 @@
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/include/mysql
- ${PCRE_INCLUDES}
+ ${PCRE_INCLUDE_DIRS}
${CMAKE_SOURCE_DIR}/sql
${SSL_INCLUDE_DIRS}
${CMAKE_SOURCE_DIR}/unittest/mytap
diff --git a/storage/perfschema/unittest/stub_pfs_global.h b/storage/perfschema/unittest/stub_pfs_global.h
index 4b792f9b..e6876dcc 100644
--- a/storage/perfschema/unittest/stub_pfs_global.h
+++ b/storage/perfschema/unittest/stub_pfs_global.h
@@ -58,7 +58,7 @@ void *pfs_malloc(PFS_builtin_memory_class *klass, size_t size, myf)
void pfs_free(PFS_builtin_memory_class *, size_t, void *ptr)
{
if (ptr != NULL)
- free(ptr);
+ aligned_free(ptr);
}
void *pfs_malloc_array(PFS_builtin_memory_class *klass, size_t n, size_t size, myf flags)