以前记录的有点问题,对于Got timeout reading communication packets记录如下:
- my_net_set_read_timeout(net, thd->variables.net_wait_timeout);
- get_command等待命令到来,注意使用的是wait_timeout超时
- 命令到来后恢复read_timeout
- my_net_set_read_timeout(net, thd->variables.net_read_timeout);
- 执行命令dispatch_command
超过read_timeout和wait_timeout报错都是一样的,
Got timeout reading communication packets
使用的是poll的timeout参数实现。
switch ((ret= poll(&pfd, 1, timeout)))
{
case -1:
/* On error, -1 is returned. */
break;
case 0:
/*
Set errno to indicate a timeout error.
(This is not compiled in on WIN32.)
*/
errno= SOCKET_ETIMEDOUT;
break;
default:
/* Ensure that the requested I/O event has completed. */
DBUG_ASSERT(pfd.revents & revents);
break;
}
官方解释:
Got Timeout Reading Communication Packets
The following considerations should be made to determine why timeout messages occur and how to avoid them:
Is the value of interactive_timeout and/or wait_timeout too small? The default values are 8 hours (28800 seconds), but if you have changed the value it may be too short for your workload. In that case, increase one or both of the values.
If the timeout values are large enough, determine why the connections are unused for extended periods of time. Examples are:
If you are using a connection pool, the pool may be too large and you can consider reducing the size or have the pool close idle connections.
A long running application may create new connections, then not use them again. In that case make sure the application closes the connection or use a connection pool.
Check the network for problems. If the network in general cannot keep up, it may be necessary to increase net_read_timeout to avoid timeouts.
解释吻合我们的分析。
网友评论