Skip to content

Commit

Permalink
Enable performance_schema.events_errors_summary_global_by_error
Browse files Browse the repository at this point in the history
Summary: Create a new variable performance_schema_ees_by_object_by_error that enables/disables all 4 detailed ees tables.

Reviewed By: george-reynya

Differential Revision: D39971029



-------------------------------------------------------------------------------------

Fix sys_vars for pfs_ee_by_object_by_error

Summary:
The sysvars test was named incorrectly, so it got picked up by the all_vars test.

Reviewed By: george-reynya

Differential Revision: D42588561
  • Loading branch information
Emily Hong authored and inikep committed May 21, 2024
1 parent 2e20f6a commit 785a24b
Show file tree
Hide file tree
Showing 14 changed files with 129 additions and 4 deletions.
4 changes: 4 additions & 0 deletions mysql-test/r/mysqld--help-notwin.result
Original file line number Diff line number Diff line change
Expand Up @@ -1318,6 +1318,9 @@ The following options may be given as the first argument:
--performance-schema-digests-size=#
Size of the statement digest. Use 0 to disable, -1 for
automated sizing.
--performance-schema-ees-by-object-by-error
Enables all 4 events_errors_summary tables
(Defaults to on; use --skip-performance-schema-ees-by-object-by-error to disable.)
--performance-schema-error-size=#
Number of server errors instrumented.
--performance-schema-esms-by-all
Expand Down Expand Up @@ -3420,6 +3423,7 @@ performance-schema-consumer-global-instrumentation TRUE
performance-schema-consumer-statements-digest TRUE
performance-schema-consumer-thread-instrumentation TRUE
performance-schema-digests-size -1
performance-schema-ees-by-object-by-error TRUE
performance-schema-error-size ####
performance-schema-esms-by-all FALSE
performance-schema-esms-by-thread-by-event-name TRUE
Expand Down
20 changes: 20 additions & 0 deletions mysql-test/suite/perfschema/r/performance_schema_ees.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
show global variables like 'performance_schema_ees_by_object_by_error';
Variable_name Value
performance_schema_ees_by_object_by_error OFF
truncate table performance_schema.events_errors_summary_global_by_error;
select * from foo;
ERROR 42S02: Table 'test.foo' doesn't exist
select ERROR_NAME, SQL_STATE, SUM_ERROR_RAISED from performance_schema.events_errors_summary_global_by_error where
SUM_ERROR_RAISED != 0 AND
SQL_STATE='42S02' AND
ERROR_NAME='ER_NO_SUCH_TABLE';
ERROR_NAME SQL_STATE SUM_ERROR_RAISED
ER_NO_SUCH_TABLE 42S02 1
select * from performance_schema.events_errors_summary_by_thread_by_error where SUM_ERROR_RAISED != 0;
THREAD_ID ERROR_NUMBER ERROR_NAME SQL_STATE SUM_ERROR_RAISED SUM_ERROR_HANDLED FIRST_SEEN LAST_SEEN
select * from performance_schema.events_errors_summary_by_account_by_error where SUM_ERROR_RAISED != 0;
USER HOST ERROR_NUMBER ERROR_NAME SQL_STATE SUM_ERROR_RAISED SUM_ERROR_HANDLED FIRST_SEEN LAST_SEEN
select * from performance_schema.events_errors_summary_by_user_by_error where SUM_ERROR_RAISED != 0;
USER ERROR_NUMBER ERROR_NAME SQL_STATE SUM_ERROR_RAISED SUM_ERROR_HANDLED FIRST_SEEN LAST_SEEN
select * from performance_schema.events_errors_summary_by_host_by_error where SUM_ERROR_RAISED != 0;
HOST ERROR_NUMBER ERROR_NAME SQL_STATE SUM_ERROR_RAISED SUM_ERROR_HANDLED FIRST_SEEN LAST_SEEN
1 change: 1 addition & 0 deletions mysql-test/suite/perfschema/r/start_server_nothing.result
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ Variable_name Value
performance_schema ON
performance_schema_accounts_size 0
performance_schema_digests_size 0
performance_schema_ees_by_object_by_error ON
performance_schema_error_size 0
performance_schema_esms_by_all OFF
performance_schema_esms_by_thread_by_event_name ON
Expand Down
8 changes: 8 additions & 0 deletions mysql-test/suite/perfschema/t/performance_schema_ees.cnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Tests for PERFORMANCE_SCHEMA
# Check server start options, read from a .cnf file

# Use default setting for mysqld processes
!include include/default_mysqld.cnf

[mysqld.1]
loose-performance_schema_ees_by_object_by_error=OFF
23 changes: 23 additions & 0 deletions mysql-test/suite/perfschema/t/performance_schema_ees.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Tests for PERFORMANCE_SCHEMA
# Check server start options, read from a .cnf file

show global variables like 'performance_schema_ees_by_object_by_error';

# Reset stats before the test
truncate table performance_schema.events_errors_summary_global_by_error;

# Generate an arbitrary error
--error ER_NO_SUCH_TABLE
select * from foo;

# Check that error exists in events_errors_summary_global_by_error table
select ERROR_NAME, SQL_STATE, SUM_ERROR_RAISED from performance_schema.events_errors_summary_global_by_error where
SUM_ERROR_RAISED != 0 AND
SQL_STATE='42S02' AND
ERROR_NAME='ER_NO_SUCH_TABLE';

# Check that granular ees tables do not exist
select * from performance_schema.events_errors_summary_by_thread_by_error where SUM_ERROR_RAISED != 0;
select * from performance_schema.events_errors_summary_by_account_by_error where SUM_ERROR_RAISED != 0;
select * from performance_schema.events_errors_summary_by_user_by_error where SUM_ERROR_RAISED != 0;
select * from performance_schema.events_errors_summary_by_host_by_error where SUM_ERROR_RAISED != 0;
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
select @@global.performance_schema_ees_by_object_by_error;
@@global.performance_schema_ees_by_object_by_error
1
select @@session.performance_schema_ees_by_object_by_error;
ERROR HY000: Variable 'performance_schema_ees_by_object_by_error' is a GLOBAL variable
show global variables like 'performance_schema_ees_by_object_by_error';
Variable_name Value
performance_schema_ees_by_object_by_error ON
show session variables like 'performance_schema_ees_by_object_by_error';
Variable_name Value
performance_schema_ees_by_object_by_error ON
select * from performance_schema.global_variables
where variable_name='performance_schema_ees_by_object_by_error';
VARIABLE_NAME VARIABLE_VALUE
performance_schema_ees_by_object_by_error ON
select * from performance_schema.session_variables
where variable_name='performance_schema_ees_by_object_by_error';
VARIABLE_NAME VARIABLE_VALUE
performance_schema_ees_by_object_by_error ON
set global performance_schema_ees_by_object_by_error = 1;
ERROR HY000: Variable 'performance_schema_ees_by_object_by_error' is a read only variable
set session performance_schema_ees_by_object_by_error = 1;
ERROR HY000: Variable 'performance_schema_ees_by_object_by_error' is a read only variable
30 changes: 30 additions & 0 deletions mysql-test/suite/sys_vars/t/pfs_ees_by_object_by_error_basic.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#
# Only global
#

select @@global.performance_schema_ees_by_object_by_error;

--error ER_INCORRECT_GLOBAL_LOCAL_VAR
select @@session.performance_schema_ees_by_object_by_error;

show global variables like 'performance_schema_ees_by_object_by_error';

show session variables like 'performance_schema_ees_by_object_by_error';

--disable_warnings
select * from performance_schema.global_variables
where variable_name='performance_schema_ees_by_object_by_error';

select * from performance_schema.session_variables
where variable_name='performance_schema_ees_by_object_by_error';
--enable_warnings

#
# Read-only
#

--error ER_INCORRECT_GLOBAL_LOCAL_VAR
set global performance_schema_ees_by_object_by_error = 1;

--error ER_INCORRECT_GLOBAL_LOCAL_VAR
set session performance_schema_ees_by_object_by_error = 1;
1 change: 1 addition & 0 deletions mysql-test/t/all_persisted_variables.test
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ let $total_excluded_vars=`SELECT COUNT(*) FROM performance_schema.global_variabl
'override_enable_raft_check',
'performance_schema_esms_by_thread_by_event_name',
'performance_schema_ews_by_thread_by_event_name',
'performance_schema_ees_by_object_by_error',
'performance_schema_histogram_enabled',
'performance_schema_max_client_attrs',
'performance_schema_sql_text_size',
Expand Down
7 changes: 7 additions & 0 deletions sql/sys_vars.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1047,6 +1047,13 @@ static Sys_var_bool Sys_pfs_ews_by_thread_by_event_name(
CMD_LINE(OPT_ARG), DEFAULT(true), NO_MUTEX_GUARD, NOT_IN_BINLOG,
ON_CHECK(NULL), ON_UPDATE(NULL), NULL, sys_var::PARSE_EARLY);

static Sys_var_bool Sys_pfs_performance_schema_ees_by_object_by_error(
"performance_schema_ees_by_object_by_error",
"Enables all 4 events_errors_summary tables",
READ_ONLY GLOBAL_VAR(pfs_param.m_performance_schema_ees_by_object_by_error),
CMD_LINE(OPT_ARG), DEFAULT(true), NO_MUTEX_GUARD, NOT_IN_BINLOG,
ON_CHECK(NULL), ON_UPDATE(NULL), NULL, sys_var::PARSE_EARLY);

static Sys_var_bool Sys_pfs_enable_histogram(
"performance_schema_histogram_enabled",
"Enables the histogram for events_statements_summary_by_all / by_digest",
Expand Down
1 change: 1 addition & 0 deletions storage/perfschema/pfs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9394,6 +9394,7 @@ void pfs_log_error_v1(uint error_num, PSI_error_operation error_operation) {
}

if (flag_thread_instrumentation &&
flag_performance_schema_ees_by_object_by_error &&
(error_stat_index < max_session_server_errors)) {
PFS_thread *pfs_thread = my_thread_get_THR_PFS();
if (unlikely(pfs_thread == nullptr)) {
Expand Down
8 changes: 4 additions & 4 deletions storage/perfschema/pfs_buffer_container.cc
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ int PFS_account_allocator::alloc_array(PFS_account_array *array) {
}
}

if (errors_sizing > 0) {
if (errors_sizing > 0 && flag_performance_schema_ees_by_object_by_error) {
array->m_instr_class_errors_array = PFS_MALLOC_ARRAY(
&builtin_memory_account_errors, errors_sizing, sizeof(PFS_error_stat),
PFS_error_stat, MYF(MY_ZEROFILL));
Expand Down Expand Up @@ -382,7 +382,7 @@ int PFS_host_allocator::alloc_array(PFS_host_array *array) {
}
}

if (errors_sizing > 0) {
if (errors_sizing > 0 && flag_performance_schema_ees_by_object_by_error) {
array->m_instr_class_errors_array = PFS_MALLOC_ARRAY(
&builtin_memory_host_errors, errors_sizing, sizeof(PFS_error_stat),
PFS_error_stat, MYF(MY_ZEROFILL));
Expand Down Expand Up @@ -598,7 +598,7 @@ int PFS_thread_allocator::alloc_array(PFS_thread_array *array) {
}
}

if (errors_sizing > 0) {
if (errors_sizing > 0 && flag_performance_schema_ees_by_object_by_error) {
array->m_instr_class_errors_array = PFS_MALLOC_ARRAY(
&builtin_memory_thread_errors, errors_sizing, sizeof(PFS_error_stat),
PFS_error_stat, MYF(MY_ZEROFILL));
Expand Down Expand Up @@ -989,7 +989,7 @@ int PFS_user_allocator::alloc_array(PFS_user_array *array) {
}
}

if (errors_sizing > 0) {
if (errors_sizing > 0 && flag_performance_schema_ees_by_object_by_error) {
array->m_instr_class_errors_array = PFS_MALLOC_ARRAY(
&builtin_memory_user_errors, errors_sizing, sizeof(PFS_error_stat),
PFS_error_stat, MYF(MY_ZEROFILL));
Expand Down
3 changes: 3 additions & 0 deletions storage/perfschema/pfs_instr_class.cc
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ uint wait_class_max = 0;
uint socket_class_start = 0;
bool flag_ews_by_thread_by_event_name = false;
bool flag_esms_by_thread_by_event_name = false;
bool flag_performance_schema_ees_by_object_by_error = false;

const char *PFS_instr_name::str() const {
DBUG_TRACE;
Expand Down Expand Up @@ -285,6 +286,8 @@ void init_event_name_sizing(const PFS_global_param *param) {
wait_class_max = socket_class_start + param->m_socket_class_sizing;
flag_ews_by_thread_by_event_name = param->m_ews_by_thread_by_event_name;
flag_esms_by_thread_by_event_name = param->m_esms_by_thread_by_event_name;
flag_performance_schema_ees_by_object_by_error =
param->m_performance_schema_ees_by_object_by_error;
}

void register_global_classes() {
Expand Down
1 change: 1 addition & 0 deletions storage/perfschema/pfs_instr_class.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ extern uint socket_class_start;
extern uint wait_class_max;
extern bool flag_ews_by_thread_by_event_name;
extern bool flag_esms_by_thread_by_event_name;
extern bool flag_performance_schema_ees_by_object_by_error;

/**
Encapsulates the name of an instrumented entity.
Expand Down
3 changes: 3 additions & 0 deletions storage/perfschema/pfs_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ struct PFS_global_param {
/** True if histogram is enabled */
bool m_histogram_enabled;

/** True if ees tables are enabled */
bool m_performance_schema_ees_by_object_by_error;

/** True if esms_by_thread_by_event_name table is enabled */
bool m_esms_by_thread_by_event_name;

Expand Down

0 comments on commit 785a24b

Please sign in to comment.