Got an error/timeout reading communication packets

一、数据库日志里面经常出现下面的信息:

Got an error reading communication packets : 一般连接异常中断时会出现下面的信息(kill 连接)

Got an timeout reading communication packets :会话长时间没有活动,超过最大的阈值时,抛出这错误(没有模拟出来)

2018-06-25T18:45:51.587445Z 123083206 [Note] Aborted connection 123083206 to db: 'semir_33' user: 'ec' host: '10.10.6.95' (Got timeout reading communication packets)
2018-06-25T18:46:03.184921Z 123267105 [Note] Aborted connection 123267105 to db: 'semir_33' user: 'ec' host: '10.10.6.95' (Got timeout reading communication packets)
2018-06-25T18:46:24.419713Z 123267256 [Note] Aborted connection 123267256 to db: 'semir_33' user: 'ec' host: '10.10.6.95' (Got timeout reading communication packets)
2018-06-26T00:00:19.480929Z 123385932 [Note] Aborted connection 123385932 to db: 'semir_33' user: 'ec' host: '10.50.13.33' (Got an error reading communication packets)
2018-06-26T01:45:37.757291Z 123420141 [Note] Aborted connection 123420141 to db: 'semir_33' user: 'ec' host: '10.50.13.33' (Got an error reading communication packets)
2018-06-26T01:56:03.058099Z 123427024 [Note] Aborted connection 123427024 to db: 'semir_33' user: 'ec' host: '10.50.13.33' (Got an error reading communication packets)

二 、数据库里存在下面两个参数


mysql> show variables like '%timeout';
+-----------------------------+----------+
| Variable_name               | Value    |
+-----------------------------+----------+
| connect_timeout             | 10       |
| wait_timeout                | 28800    |
+-----------------------------+----------+
mysql> show global status like '%abort%';
+------------------+-------+
| Variable_name    | Value |
+------------------+-------+
| Aborted_clients  | 1     | -- kill 会话后,该值会自增
| Aborted_connects | 7     | -- 用2.2 模拟连接 ,超时后该值会自增
+------------------+-------+


2.1 什么是connect timeout  (是指tcp 连接,需要三次握手)

也就是client 发出 syn 包,server端在你指定的时间内没有回复ack,poll/select 返回0

server 端为什么没有回复ack, 因为syn包的回复是内核层的,要么网络层丢包,要么就是内核层back_log的queue满了,关于backlog在本片中就不详细描述了。

当时查看产线上的连接最高能到1000多,同时查看了backlog 的queue的大小

?
1
cat /proc/sys/net/ipv4/tcp_max_syn_backlog

有8192 在产线上没有这么多的客户端的连接,不可能backlog queue会满,虽然syn_backlog 的设置是8192 但并不代表服务器启动的时候设置成了8192,所以必须查这个端口所设置的backlog大小

?
1
ss -lt

看到Send-Q在8080端口是128 ,原来在服务器端启动listen 的时候设置了128的backlog 


2.2 可以通过 telnet 10.10.19.202 3306 来进行模拟 tcp 连接失败的

猜你喜欢

转载自blog.csdn.net/huangliang0703/article/details/80814339