Browse Source

Add tests and code instrumentations

10.10-MDEV-16440
Nikita Malyavin 4 years ago
parent
commit
520fafd280
  1. 20
      mysql-test/suite/perfschema/r/show_coverage.result
  2. 32
      mysql-test/suite/perfschema/r/show_plugin.result
  3. 154
      mysql-test/suite/perfschema/r/variables_by_thread.result
  4. 22
      mysql-test/suite/perfschema/t/show_coverage.test
  5. 8
      mysql-test/suite/perfschema/t/show_plugin.test
  6. 4
      mysql-test/suite/perfschema/t/variables_by_thread.combinations
  7. 157
      mysql-test/suite/perfschema/t/variables_by_thread.test
  8. 2
      sql/my_apc.cc
  9. 1
      sql/sql_class.cc
  10. 5
      sql/sql_parse.cc
  11. 5
      storage/perfschema/pfs_variable.cc

20
mysql-test/suite/perfschema/r/show_coverage.result

@ -96,23 +96,3 @@ FLUSH STATUS;
#
include/assert.inc [Global value requested from the default session after FLUSH must remain the same]
include/assert.inc [Default session value after FLUSH must remain zero]
# BUG: results from inactive connections are not shown
SET time_zone= '+2:00';
connect con1, localhost, root,,;
set time_zone= '+10:00';
SELECT THREAD_ID INTO @con1_thread_id FROM performance_schema.threads
WHERE PROCESSLIST_ID = CONNECTION_ID();
SELECT thread_id = @con1_thread_id as current, variable_value
FROM performance_schema.variables_by_thread
WHERE variable_name = "time_zone";
current variable_value
1 +10:00
disconnect con1;
connection default;
SELECT THREAD_ID INTO @def_thread_id FROM performance_schema.threads
WHERE PROCESSLIST_ID = CONNECTION_ID();
SELECT thread_id = @def_thread_id as current, variable_value
FROM performance_schema.variables_by_thread
WHERE variable_name = "time_zone";
current variable_value
1 +02:00

32
mysql-test/suite/perfschema/r/show_plugin.result

@ -411,11 +411,23 @@ example_varopt_default 5
#
# Variables by thread
SELECT variable_name, variable_value FROM performance_schema.variables_by_thread
WHERE variable_name LIKE "example_%" ORDER BY variable_value;
WHERE variable_name LIKE "example_%" ORDER BY variable_value, variable_name;
variable_name variable_value
example_deprecated_var 0
example_deprecated_var 0
example_deprecated_var 0
example_deprecated_var 0
example_int_var 0
example_int_var 0
example_int_var 0
example_int_var 0
example_double_thdvar 300.000000
example_double_thdvar 300.111100
example_double_thdvar 300.222200
example_double_thdvar 300.333300
example_varopt_default 5
example_varopt_default 5
example_varopt_default 5
example_varopt_default 5
#
# ================================================================================
@ -489,7 +501,7 @@ example_varopt_default 5
#
# Variables by thread
SELECT variable_name, variable_value FROM performance_schema.variables_by_thread
WHERE variable_name LIKE "example_%" ORDER BY variable_value;
WHERE variable_name LIKE "example_%" ORDER BY variable_value, variable_name;
variable_name variable_value
example_deprecated_var 0
example_int_var 0
@ -570,11 +582,23 @@ example_varopt_default 5
#
# Variables by thread
SELECT variable_name, variable_value FROM performance_schema.variables_by_thread
WHERE variable_name LIKE "example_%" ORDER BY variable_value;
WHERE variable_name LIKE "example_%" ORDER BY variable_value, variable_name;
variable_name variable_value
example_deprecated_var 0
example_deprecated_var 0
example_deprecated_var 0
example_deprecated_var 0
example_int_var 0
example_int_var 0
example_int_var 0
example_int_var 0
example_double_thdvar 300.000000
example_double_thdvar 311.111100
example_double_thdvar 322.222200
example_double_thdvar 333.333300
example_varopt_default 5
example_varopt_default 5
example_varopt_default 5
example_varopt_default 5
#
# ================================================================================
@ -612,7 +636,7 @@ variable_name variable_value
#
# VARIABLES BY THREAD
SELECT variable_name, variable_value FROM performance_schema.variables_by_thread
WHERE variable_name LIKE "example_%" ORDER BY variable_value;
WHERE variable_name LIKE "example_%" ORDER BY variable_value, variable_name;
variable_name variable_value
#
# ================================================================================

154
mysql-test/suite/perfschema/r/variables_by_thread.result

@ -0,0 +1,154 @@
#
# Results from inactive connections are shown
#
SET time_zone= '+2:00';
SELECT THREAD_ID INTO @def_thread_id FROM performance_schema.threads
WHERE PROCESSLIST_ID = CONNECTION_ID();
connect con2, localhost, root,,;
connect con1, localhost, root,,;
set time_zone= '+10:00';
SELECT THREAD_ID INTO @con1_thread_id FROM performance_schema.threads
WHERE PROCESSLIST_ID = CONNECTION_ID();
SELECT thread_id = @con1_thread_id as current, variable_value
FROM performance_schema.variables_by_thread
WHERE variable_name = "time_zone";
current variable_value
0 +02:00
0 SYSTEM
1 +10:00
connection con2;
connection default;
SELECT thread_id = @def_thread_id as current, variable_value
FROM performance_schema.variables_by_thread
WHERE variable_name = "time_zone";
current variable_value
1 +02:00
0 SYSTEM
0 +10:00
#
# Notify APC before net_read
#
connection con2;
select "good";
good
good
connection con1;
set debug_sync= "before_do_command_net_read SIGNAL net WAIT_FOR pass";
connection default;
set debug_sync= "now WAIT_FOR net";
set debug_sync= "apc_after_notify SIGNAL pass";
SELECT thread_id = @def_thread_id as current, variable_value
FROM performance_schema.variables_by_thread
WHERE variable_name = "time_zone";
current variable_value
1 +02:00
0 SYSTEM
0 +10:00
set debug_sync= "now SIGNAL pass";
connection con1;
connection default;
#
# Test timeout
#
set @old_dbug= @@global.debug_dbug;
set global debug_dbug= "+d,apc_timeout";
connection con2;
select "good";
good
good
connection con1;
set debug_sync= "now SIGNAL waiting WAIT_FOR pass";
connection default;
set debug_sync= "now WAIT_FOR waiting";
# Should timeout in 1ms.
SELECT thread_id = @def_thread_id as current, variable_value
FROM performance_schema.variables_by_thread
WHERE variable_name = "time_zone"
and thread_id in (@def_thread_id,
@con1_thread_id);
current variable_value
1 +02:00
set debug_sync= "now SIGNAL pass";
connection con1;
SELECT "ok";
ok
ok
connection con2;
select "good";
good
good
connection default;
set global debug_dbug= @old_dbug;
#
# Two requests
#
connection con1;
set debug_sync= "before_do_command_net_read SIGNAL net WAIT_FOR pass";
SELECT "work";
connection con2;
set debug_sync= "now WAIT_FOR net";
set debug_sync= "apc_after_notify SIGNAL con2_hangs";
SELECT thread_id = @con1_thread_id as `con1's`, variable_value
FROM performance_schema.variables_by_thread
WHERE variable_name = "time_zone";
connection default;
set debug_sync= "now WAIT_FOR con2_hangs";
set debug_sync= "apc_after_notify SIGNAL pass";
SELECT thread_id = @def_thread_id as current, variable_value
FROM performance_schema.variables_by_thread
WHERE variable_name = "time_zone";
current variable_value
1 +02:00
0 SYSTEM
0 +10:00
connection con1;
work
work
connection con2;
con1's variable_value
0 +02:00
0 SYSTEM
1 +10:00
select "good";
good
good
#
# Result from the killed query is shown.
#
connection con1;
set debug_sync= "after_dispatch_command SIGNAL dispatched WAIT_FOR pass";
SELECT "work";
connection default;
set debug_sync= "now WAIT_FOR dispatched";
KILL QUERY @con1_kill_thread_id;
connection default;
SELECT thread_id = @def_thread_id as current, variable_value
FROM performance_schema.variables_by_thread
WHERE variable_name = "time_zone";
current variable_value
1 +02:00
0 SYSTEM
0 +10:00
set debug_sync= "now SIGNAL pass";
#
# Result from the killed connection is ignored.
#
connection con1;
work
work
set debug_sync= "after_dispatch_command SIGNAL dispatched WAIT_FOR pass";
SELECT "work";
connection default;
set debug_sync= "now WAIT_FOR dispatched";
KILL CONNECTION @con1_kill_thread_id;
SELECT thread_id = @def_thread_id as current, variable_value
FROM performance_schema.variables_by_thread
WHERE variable_name = "time_zone";
current variable_value
1 +02:00
0 SYSTEM
# Cleanup
connection default;
set debug_sync= "reset";
disconnect con1;
disconnect con2;

22
mysql-test/suite/perfschema/t/show_coverage.test

@ -143,25 +143,3 @@ FLUSH STATUS;
--let $assert_text = Default session value after FLUSH must remain zero
--source include/assert.inc
--echo # BUG: results from inactive connections are not shown
SET time_zone= '+2:00';
--connect (con1, localhost, root,,)
set time_zone= '+10:00';
SELECT THREAD_ID INTO @con1_thread_id FROM performance_schema.threads
WHERE PROCESSLIST_ID = CONNECTION_ID();
SELECT thread_id = @con1_thread_id as current, variable_value
FROM performance_schema.variables_by_thread
WHERE variable_name = "time_zone";
--disconnect con1
--connection default
SELECT THREAD_ID INTO @def_thread_id FROM performance_schema.threads
WHERE PROCESSLIST_ID = CONNECTION_ID();
SELECT thread_id = @def_thread_id as current, variable_value
FROM performance_schema.variables_by_thread
WHERE variable_name = "time_zone";

8
mysql-test/suite/perfschema/t/show_plugin.test

@ -175,7 +175,7 @@ SET SESSION example_double_thdvar = 300.3333;
--echo #
--echo # Variables by thread
SELECT variable_name, variable_value FROM performance_schema.variables_by_thread
WHERE variable_name LIKE "example_%" ORDER BY variable_value;
WHERE variable_name LIKE "example_%" ORDER BY variable_value, variable_name;
--echo #
--echo # ================================================================================
@ -203,7 +203,7 @@ WHERE variable_name LIKE "example_%" ORDER BY variable_value;
--echo #
--echo # Variables by thread
SELECT variable_name, variable_value FROM performance_schema.variables_by_thread
WHERE variable_name LIKE "example_%" ORDER BY variable_value;
WHERE variable_name LIKE "example_%" ORDER BY variable_value, variable_name;
--echo #
--echo # ================================================================================
@ -228,7 +228,7 @@ SET SESSION example_double_thdvar = 333.3333;
--echo #
--echo # Variables by thread
SELECT variable_name, variable_value FROM performance_schema.variables_by_thread
WHERE variable_name LIKE "example_%" ORDER BY variable_value;
WHERE variable_name LIKE "example_%" ORDER BY variable_value, variable_name;
--echo #
--echo # ================================================================================
@ -244,7 +244,7 @@ UNINSTALL PLUGIN example;
--echo #
--echo # VARIABLES BY THREAD
SELECT variable_name, variable_value FROM performance_schema.variables_by_thread
WHERE variable_name LIKE "example_%" ORDER BY variable_value;
WHERE variable_name LIKE "example_%" ORDER BY variable_value, variable_name;
--echo #
--echo # ================================================================================

4
mysql-test/suite/perfschema/t/variables_by_thread.combinations

@ -0,0 +1,4 @@
[thread-per-connection]
thread-handling=one-thread-per-connection
[tpool]
thread-handling=pool-of-threads

157
mysql-test/suite/perfschema/t/variables_by_thread.test

@ -0,0 +1,157 @@
--source include/have_perfschema.inc
--source include/have_debug_sync.inc
--source include/not_embedded.inc
--echo #
--echo # Results from inactive connections are shown
--echo #
SET time_zone= '+2:00';
SELECT THREAD_ID INTO @def_thread_id FROM performance_schema.threads
WHERE PROCESSLIST_ID = CONNECTION_ID();
--connect (con2, localhost, root,,)
--connect (con1, localhost, root,,)
set time_zone= '+10:00';
SELECT THREAD_ID INTO @con1_thread_id FROM performance_schema.threads
WHERE PROCESSLIST_ID = CONNECTION_ID();
let $con1_thread_id= `select @con1_thread_id`;
let $con1_kill_thread_id= `select CONNECTION_ID()`;
SELECT thread_id = @con1_thread_id as current, variable_value
FROM performance_schema.variables_by_thread
WHERE variable_name = "time_zone";
--connection con2
--disable_query_log
eval set @con1_thread_id= $con1_thread_id;
eval set @con1_kill_thread_id= $con1_kill_thread_id;
--enable_query_log
--connection default
--disable_query_log
eval set @con1_thread_id= $con1_thread_id;
eval set @con1_kill_thread_id= $con1_kill_thread_id;
--enable_query_log
SELECT thread_id = @def_thread_id as current, variable_value
FROM performance_schema.variables_by_thread
WHERE variable_name = "time_zone";
--echo #
--echo # Notify APC before net_read
--echo #
--connection con2
select "good";
--connection con1
--send
set debug_sync= "before_do_command_net_read SIGNAL net WAIT_FOR pass";
--connection default
set debug_sync= "now WAIT_FOR net";
set debug_sync= "apc_after_notify SIGNAL pass";
SELECT thread_id = @def_thread_id as current, variable_value
FROM performance_schema.variables_by_thread
WHERE variable_name = "time_zone";
set debug_sync= "now SIGNAL pass";
--connection con1
--reap
--connection default
--echo #
--echo # Test timeout
--echo #
set @old_dbug= @@global.debug_dbug;
set global debug_dbug= "+d,apc_timeout";
--connection con2
select "good";
--connection con1
--send
set debug_sync= "now SIGNAL waiting WAIT_FOR pass";
--connection default
set debug_sync= "now WAIT_FOR waiting";
--echo # Should timeout in 1ms.
SELECT thread_id = @def_thread_id as current, variable_value
FROM performance_schema.variables_by_thread
WHERE variable_name = "time_zone"
and thread_id in (@def_thread_id,
@con1_thread_id); # con2 can be nondeterministically skipped
set debug_sync= "now SIGNAL pass";
--connection con1
--reap
SELECT "ok";
--connection con2
select "good";
--connection default
set global debug_dbug= @old_dbug;
--echo #
--echo # Two requests
--echo #
--connection con1
set debug_sync= "before_do_command_net_read SIGNAL net WAIT_FOR pass";
--send
SELECT "work";
--connection con2
set debug_sync= "now WAIT_FOR net";
set debug_sync= "apc_after_notify SIGNAL con2_hangs";
--send
SELECT thread_id = @con1_thread_id as `con1's`, variable_value
FROM performance_schema.variables_by_thread
WHERE variable_name = "time_zone";
--connection default
set debug_sync= "now WAIT_FOR con2_hangs";
set debug_sync= "apc_after_notify SIGNAL pass";
SELECT thread_id = @def_thread_id as current, variable_value
FROM performance_schema.variables_by_thread
WHERE variable_name = "time_zone";
--connection con1
--reap
--connection con2
--reap
select "good";
--echo #
--echo # Result from the killed query is shown.
--echo #
--connection con1
set debug_sync= "after_dispatch_command SIGNAL dispatched WAIT_FOR pass";
--send
SELECT "work";
--connection default
set debug_sync= "now WAIT_FOR dispatched";
KILL QUERY @con1_kill_thread_id;
--connection default
SELECT thread_id = @def_thread_id as current, variable_value
FROM performance_schema.variables_by_thread
WHERE variable_name = "time_zone";
set debug_sync= "now SIGNAL pass";
--echo #
--echo # Result from the killed connection is ignored.
--echo #
--connection con1
--reap
set debug_sync= "after_dispatch_command SIGNAL dispatched WAIT_FOR pass";
--send
SELECT "work";
--connection default
set debug_sync= "now WAIT_FOR dispatched";
KILL CONNECTION @con1_kill_thread_id;
SELECT thread_id = @def_thread_id as current, variable_value
FROM performance_schema.variables_by_thread
WHERE variable_name = "time_zone";
--echo # Cleanup
--connection default
set debug_sync= "reset";
--disconnect con1
--disconnect con2

2
sql/my_apc.cc

@ -132,6 +132,8 @@ int Apc_target::wait_for_completion(THD *caller_thd, Call_request *apc_request,
struct timespec abstime;
const int timeout= timeout_sec;
set_timespec(abstime, timeout);
DBUG_EXECUTE_IF("apc_timeout", set_timespec_nsec(abstime, 1000000););
int res = 1;
int wait_res= 0;
PSI_stage_info old_stage;

1
sql/sql_class.cc

@ -4383,6 +4383,7 @@ void thd_net_process_apc_requests(THD *thd)
#endif
if (unlikely(thd->apc_target.have_apc_requests()))
thd->apc_target.process_apc_requests();
DEBUG_SYNC(thd, "net_after_apc");
#ifdef WIN32
SetLastError(last_error);
#else

5
sql/sql_parse.cc

@ -1296,7 +1296,8 @@ dispatch_command_return do_command(THD *thd, bool blocking)
goto out;
}
thd->apc_target.process_apc_requests();
if (unlikely(thd->apc_target.have_apc_requests()))
thd->apc_target.process_apc_requests();
packet= (char*) net->read_pos;
/*
@ -1408,6 +1409,8 @@ dispatch_command_return do_command(THD *thd, bool blocking)
resume:
return_value= dispatch_command(command, thd, packet+1,
(uint) (packet_length-1), blocking);
DEBUG_SYNC(thd, "after_dispatch_command");
if (return_value == DISPATCH_COMMAND_WOULDBLOCK)
{
/* Save current state, and resume later.*/

5
storage/perfschema/pfs_variable.cc

@ -384,7 +384,7 @@ void PFS_system_variable_cache::refresh_one_var(uint index)
int PFS_system_variable_cache::make_call(Request_func func, uint param)
{
int ret= 0;
THD *requestor_thd= current_thd;
THD *requestor_thd= m_current_thd;
if (requestor_thd == m_safe_thd)
{
mysql_mutex_unlock(&m_safe_thd->LOCK_thd_kill);
@ -404,8 +404,9 @@ int PFS_system_variable_cache::make_call(Request_func func, uint param)
return 1;
}
}
DEBUG_SYNC(requestor_thd, "apc_after_notify");
ret= m_safe_thd->apc_target.wait_for_completion(requestor_thd, request,
30);
10);
if (ret == 0)
delete request;
}

Loading…
Cancel
Save