客户端执行 set global global_sleep_time=100;
调用堆栈信息
#0 set_tmp_open_sleep (self=0x2d8e5c0 <Sys_tmp_sleep_time>, thd=0x7ff4c4000b70, type=OPT_GLOBAL) at /root/mysql-5.7.27_edit_malloc_log/sql/sys_vars.cc:3916
#1 0x00000000014a869f in sys_var::update (this=0x2d8e5c0 <Sys_tmp_sleep_time>, thd=0x7ff4c4000b70, var=0x7ff4c40063e0) at /root/mysql-5.7.27_edit_malloc_log/sql/set_var.cc:184
#2 0x00000000014a9d3a in set_var::update (this=0x7ff4c40063e0, thd=0x7ff4c4000b70) at /root/mysql-5.7.27_edit_malloc_log/sql/set_var.cc:822
#3 0x00000000014a962c in sql_set_variables (thd=0x7ff4c4000b70, var_list=0x7ff4c4003268) at /root/mysql-5.7.27_edit_malloc_log/sql/set_var.cc:662
#4 0x000000000156e066 in mysql_execute_command (thd=0x7ff4c4000b70, first_level=true) at /root/mysql-5.7.27_edit_malloc_log/sql/sql_parse.cc:3707
#5 0x00000000015733d9 in mysql_parse (thd=0x7ff4c4000b70, parser_state=0x7fffec217680) at /root/mysql-5.7.27_edit_malloc_log/sql/sql_parse.cc:5570
#6 0x0000000001568a58 in dispatch_command (thd=0x7ff4c4000b70, com_data=0x7fffec217e10, command=COM_QUERY) at /root/mysql-5.7.27_edit_malloc_log/sql/sql_parse.cc:1484
#7 0x00000000015678a4 in do_command (thd=0x7ff4c4000b70) at /root/mysql-5.7.27_edit_malloc_log/sql/sql_parse.cc:1025
#8 0x000000000169767d in handle_connection (arg=0x8036abb0) at /root/mysql-5.7.27_edit_malloc_log/sql/conn_handler/connection_handler_per_thread.cc:306
#9 0x0000000001d37162 in pfs_spawn_thread (arg=0x804239a0) at /root/mysql-5.7.27_edit_malloc_log/storage/perfschema/pfs.cc:2190
#10 0x00007ffff7bc6e65 in start_thread () from /lib64/libpthread.so.0
#11 0x00007ffff660788d in clone () from /lib64/libc.so.6
(gdb)
变量的定义
ulong tmp_sleep_time;
static bool set_tmp_open_sleep(sys_var *self, THD *thd, enum_var_type type)
{
malloc_sleep_time =tmp_sleep_time;
return false;
}
static Sys_var_ulong Sys_tmp_sleep_time(
“global_sleep_time”,
“global_sleep_time”,
GLOBAL_VAR(tmp_sleep_time), CMD_LINE(REQUIRED_ARG),
VALID_RANGE(0, ULONG_MAX), DEFAULT(0),BLOCK_SIZE(1), NO_MUTEX_GUARD,
NOT_IN_BINLOG, ON_CHECK(0), ON_UPDATE(set_tmp_open_sleep));