ERROR 1160 (08S01) : Got an error writing communication packets

本文涉及的产品
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS PostgreSQL,集群系列 2核4GB
简介:     应用程序端碰到错误提示,MySQLNonTransientConnectionException:Got an error writing communication packets。


    应用程序端碰到错误提示,MySQLNonTransientConnectionException:Got an error writing communication packets。与packet有关,之前一直都没有碰到过这个问题。数据库error日志也未见半点异常,到底是怎么一回事呢?


1、故障现象
故障环境:
$ cat /etc/issue
CentOS release 5.9 (Final)
Kernel \r on an \m

[mysql@GZ-DB-MASTER01 ~]$ mysql --version
mysql  Ver 14.14 Distrib 5.6.12, for Linux (x86_64) using  EditLine wrapper

客户端抛出的异常:MySQLNonTransientConnectionException:Got an error writing communication packets
数据库服务器端异常:
mysql> flush tables;
ERROR 1160 (08S01): Got an error writing communication packets

--由于使用了federated引擎,客户端查询的表为federated,以为是bug呢
--而直接查询federated是ok的,有可能是返回的数据量没有达到设置值的缘故,因为我们只是简单的count

mysql> select count(*) from tadv_gold;
+----------+
| count(*) |
+----------+
|    31525 |
+----------+
1 row in set (0.46 sec)

mysql> select count(*) from tadv_invest_record;
+----------+
| count(*) |
+----------+
|     6761 |
+----------+
1 row in set (0.08 sec)


二、分析与解决
MySQL监控看到了Slave has max_allowed_packet size less than master的提示,下面是这个问题的描述:
Each slave in a replication topology should have a max_allowed_packet size at least as large as its master's. The max_allowed_packet variable sets an upper limit on the size of any single message between the MySQL server and clients, including replication slaves. If you are replicating large column values (such as might be found in TEXT or BLOB columns) and max_allowed_packet is too small on the master, the master fails with an error, and the slave shuts down the I/O thread. If max_allowed_packet is too small on the slave, this also causes the slave to stop the I/O thread.


建议:
Investigate why slave SZ-DB-SRV01:3307 has a max_allowed_packet size of 4 MiB, which is less than master SZ-DB-SRV01:3306s max_allowed_packet size of 16 MiB.

Links and Further Reading
MySQL Manual: Replication and max-allowed-packet
MySQL Manual: System Variable Index - M
MySQL Manual: Server System Variables
set global max_allowed_packet=16777216

--上面的描述是主从之间的参数max_allowed_packet不一致,似乎与本文的问题无关
--因为我们从该库调用的federated引擎目标表并不位于这个packet值过小的从库,而是另外一个实例。
--即使从库设置的过小,理论上应该不影响当前库federated到另一实例的message大小值。
--还是尝试进行了修改,因为调整到16MB,对当前的硬件影响不会太大。

mysql> show variables like '%packet%';
+--------------------------+------------+
| Variable_name            | Value      |
+--------------------------+------------+
| max_allowed_packet       | 4194304    |
| slave_max_allowed_packet | 1073741824 |
+--------------------------+------------+
2 rows in set (0.00 sec)

mysql> set global max_allowed_packet=16777216;
Query OK, 0 rows affected (0.00 sec)

mysql> show global variables like '%packet%';
+--------------------------+------------+
| Variable_name            | Value      |
+--------------------------+------------+
| max_allowed_packet       | 16777216   |
| slave_max_allowed_packet | 1073741824 |
+--------------------------+------------+
2 rows in set (0.00 sec)

--再次flush tables,成功鸟。
mysql> flush tables;                   --Author: Leshami
Query OK, 0 rows affected (0.03 sec)   --Blog  :
http://blog.csdn.net/leshami


3、关于参数max_allowed_packet
The maximum size of one packet or any generated/intermediate string, or any parameter sent by the mysql_stmt_send_long_data() C API function. The default is 4MB as of MySQL 5.6.6, 1MB before that.


The packet message buffer is initialized to net_buffer_length bytes, but can grow up to max_allowed_packet. You must increase this value if you are using large BLOB columns or long strings. It should be as big as the largest BLOB you want to use. The protocol limit for max_allowed_packet is 1GB. The value should be a multiple of 1024; nonmultiples are rounded down to the nearest multiple. When you change the message buffer size by changing the value of the max_allowed_packet variable, you should also change the buffer size on the client side if your client program permits it. The default max_allowed_packet value built in to the client library is 1GB, but individual client programs might override this. For example, mysql and mysqldump have defaults of 16MB and 24MB, respectively. They also enable you to change the client-side value by setting max_allowed_packet on the command line or in an option file.The session value of this variable is read only.

补充@20150528:关于这个问题,存在一个Bug,在metalink上可以找到相关文档,ID 1595441.1


相关实践学习
如何在云端创建MySQL数据库
开始实验后,系统会自动创建一台自建MySQL的 源数据库 ECS 实例和一台 目标数据库 RDS。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
相关文章
|
资源调度
There appears to be trouble with your network connection.Retrying
There appears to be trouble with your network connection.Retrying
2032 0
There appears to be trouble with your network connection.Retrying
Error: error:0308010C:digital envelope routines::unsupported
Error: error:0308010C:digital envelope routines::unsupported
|
6月前
|
Linux Windows
【已解决】Error: error:0308010C:digital envelope routines::unsupported
【已解决】Error: error:0308010C:digital envelope routines::unsupported
200 0
|
7月前
|
JavaScript 算法 Windows
95% emitting CompressionPlugin ERROR Error: error:0308010C:digital envelope routines::unsupported
95% emitting CompressionPlugin ERROR Error: error:0308010C:digital envelope routines::unsupported
883 0
|
7月前
|
算法 JavaScript
解决Error: error:0308010C:digital envelope routines::unsupported最快速方案
解决Error: error:0308010C:digital envelope routines::unsupported最快速方案
269 0
ERROR: Encountered errors while bringing up the project.
ERROR: Encountered errors while bringing up the project.
168 0
排错-Error--memory violation Exception ACCESS_VIOLATION received解决方
排错-Error--memory violation Exception ACCESS_VIOLATION received解决方
229 0
SignTool Error: An error occurred while attempting/Error information: “SignerTimeStamp() failed.“
SignTool Error: An error occurred while attempting/Error information: “SignerTimeStamp() failed.“
151 0
abort: error: Temporary failure in name resolution
abort: error: Temporary failure in name resolution
200 0
|
资源调度 JavaScript
The futex facility returned an unexpected error code
The futex facility returned an unexpected error code
825 0