简单记录
static bool login_connection(THD *thd) {
int error;
DBUG_TRACE;
DBUG_PRINT("info",
("login_connection called by thread %u", thd->thread_id()));
/* Use "connect_timeout" value during connection phase */
thd->get_protocol_classic()->set_read_timeout(connect_timeout);
thd->get_protocol_classic()->set_write_timeout(connect_timeout);
error = check_connection(thd);
thd->send_statement_status();
if (error) { // Wrong permissions
#ifdef _WIN32
if (vio_type(thd->get_protocol_classic()->get_vio()) == VIO_TYPE_NAMEDPIPE)
my_sleep(1000); /* must wait after eof() */
#endif
return true;
}
/* Connect completed, set read/write timeouts back to default */
thd->get_protocol_classic()->set_read_timeout(
thd->variables.net_read_timeout);
thd->get_protocol_classic()->set_write_timeout(
thd->variables.net_write_timeout);
return false;
}
(gdb) n
700 thd->get_protocol_classic()->set_read_timeout(connect_timeout);
(gdb) n
701 thd->get_protocol_classic()->set_write_timeout(connect_timeout);
(gdb) p connect_timeout
$1 = 10
(gdb)
用于handshake阶段,验证信息阶段的超时,stack如下:
(gdb) bt
#0 net_write_packet (net=0x7ffee4368c68, packet=0x7ffee4000b10 "P", length=84) at /opt/mysql/mysql-8.0.21/sql-common/net_serv.cc:1274
#1 0x000000000390e119 in net_flush (net=0x7ffee4368c68) at /opt/mysql/mysql-8.0.21/sql-common/net_serv.cc:276
#2 0x0000000003d3e7d8 in Protocol_classic::flush (this=0x7ffee43a7900) at /opt/mysql/mysql-8.0.21/sql/protocol_classic.cc:2863
#3 0x0000000003999721 in send_server_handshake_packet (mpvio=0x7fff60089130, data=0x7fff60088bb0 "xP>X\016uo~\033\001kHg\027S\020\017\020\062\036", data_len=21)
at /opt/mysql/mysql-8.0.21/sql/auth/sql_authentication.cc:1463
#4 0x000000000399d4b9 in server_mpvio_write_packet (param=0x7fff60089130, packet=0x7fff60088bb0 "xP>X\016uo~\033\001kHg\027S\020\017\020\062\036", packet_len=21)
at /opt/mysql/mysql-8.0.21/sql/auth/sql_authentication.cc:2853
#5 0x0000000003a49db7 in caching_sha2_password_authenticate (vio=0x7fff60089130, info=0x7fff60089158) at /opt/mysql/mysql-8.0.21/sql/auth/sha2_password.cc:946
#6 0x000000000399da4d in do_auth_once (thd=0x7ffee4367140, auth_plugin_name=..., mpvio=0x7fff60089130) at /opt/mysql/mysql-8.0.21/sql/auth/sql_authentication.cc:2996
#7 0x000000000399ec49 in acl_authenticate (thd=0x7ffee4367140, command=COM_CONNECT) at /opt/mysql/mysql-8.0.21/sql/auth/sql_authentication.cc:3327
#8 0x00000000036aa0b7 in check_connection (thd=0x7ffee4367140) at /opt/mysql/mysql-8.0.21/sql/sql_connect.cc:648
#9 0x00000000036aa258 in login_connection (thd=0x7ffee4367140) at /opt/mysql/mysql-8.0.21/sql/sql_connect.cc:703
#10 0x00000000036ab10c in thd_prepare_connection (thd=0x7ffee4367140) at /opt/mysql/mysql-8.0.21/sql/sql_connect.cc:876
#11 0x000000000391532f in handle_connection (arg=0x97e5d90) at /opt/mysql/mysql-8.0.21/sql/conn_handler/connection_handler_per_thread.cc:298
#12 0x00000000054bf7d1 in pfs_spawn_thread (arg=0xa7c23d0) at /opt/mysql/mysql-8.0.21/storage/perfschema/pfs.cc:2880
#13 0x00007ffff7bc6ea5 in start_thread () from /lib64/libpthread.so.0
#14 0x00007ffff5e388dd in clone () from /lib64/libc.so.6
(gdb) c
Continuing.
Breakpoint 3, net_write_packet (net=0x7ffee4368c68, packet=0x7ffee4000b10 "\a", length=11) at /opt/mysql/mysql-8.0.21/sql-common/net_serv.cc:1274
1274 DBUG_TRACE;
(gdb) bt
#0 net_write_packet (net=0x7ffee4368c68, packet=0x7ffee4000b10 "\a", length=11) at /opt/mysql/mysql-8.0.21/sql-common/net_serv.cc:1274
#1 0x000000000390e119 in net_flush (net=0x7ffee4368c68) at /opt/mysql/mysql-8.0.21/sql-common/net_serv.cc:276
#2 0x0000000003d3ced4 in net_send_ok (thd=0x7ffee4367140, server_status=2, statement_warn_count=0, affected_rows=0, id=0, message=0x7ffee4369710 "", eof_identifier=false)
at /opt/mysql/mysql-8.0.21/sql/protocol_classic.cc:964
#3 0x0000000003d3d5ce in Protocol_classic::send_ok (this=0x7ffee43a7900, server_status=2, statement_warn_count=0, affected_rows=0, last_insert_id=0, message=0x7ffee4369710 "")
at /opt/mysql/mysql-8.0.21/sql/protocol_classic.cc:1302
#4 0x000000000369aa07 in THD::send_statement_status (this=0x7ffee4367140) at /opt/mysql/mysql-8.0.21/sql/sql_class.cc:2646
#5 0x00000000036aa267 in login_connection (thd=0x7ffee4367140) at /opt/mysql/mysql-8.0.21/sql/sql_connect.cc:704
#6 0x00000000036ab10c in thd_prepare_connection (thd=0x7ffee4367140) at /opt/mysql/mysql-8.0.21/sql/sql_connect.cc:876
#7 0x000000000391532f in handle_connection (arg=0x97e5d90) at /opt/mysql/mysql-8.0.21/sql/conn_handler/connection_handler_per_thread.cc:298
#8 0x00000000054bf7d1 in pfs_spawn_thread (arg=0xa7c23d0) at /opt/mysql/mysql-8.0.21/storage/perfschema/pfs.cc:2880
#9 0x00007ffff7bc6ea5 in start_thread () from /lib64/libpthread.so.0
#10 0x00007ffff5e388dd in clone () from /lib64/libc.so.6
平时do command用的是 read timeout和read timeout 参数
网友评论