前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >ERROR 1160 (08S01) : Got an error writing communication packets

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

作者头像
Leshami
发布2018-08-08 17:58:14
2.8K0
发布2018-08-08 17:58:14
举报
文章被收录于专栏:乐沙弥的世界乐沙弥的世界

    应用程序端碰到错误提示,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

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2015年05月19日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
云数据库 MySQL
腾讯云数据库 MySQL(TencentDB for MySQL)为用户提供安全可靠,性能卓越、易于维护的企业级云数据库服务。其具备6大企业级特性,包括企业级定制内核、企业级高可用、企业级高可靠、企业级安全、企业级扩展以及企业级智能运维。通过使用腾讯云数据库 MySQL,可实现分钟级别的数据库部署、弹性扩展以及全自动化的运维管理,不仅经济实惠,而且稳定可靠,易于运维。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档