ERROR 1160 (08S01) : 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



时间: 2024-08-01 22:32:45

ERROR 1160 (08S01) : Got an error writing communication packets的相关文章

Curl POST to HTTPS url gives SSLRead() error:curl: (56) SSLRead() return error -9806

当系统升级到OSX 10.10.3的时候,用brew更新软件安装包,出现了curl抛出的错误. ==> Upgrading boost ==> Downloading https://homebrew.bintray.com/bottles/boost-1.58.0.yosemite.bottle.tar.gz 0.7% curl: (56) SSLRead() return error -9806 Error: Failed to download resource "boost&

MS SQL Could not obtain information about Windows NT group/user 'domain\login', error code 0x5. [SQLSTATE 42000] (Error 15404)

最近碰到一个有趣的错误:海外的一台数据库服务器上某些作业偶尔会报错,报错信息如下所示: ------------------------------------------------------------------------------------------------------------------------------------------------- 日期 2013/9/15 12:00:00 日志 作业历史记录 (JOB_SYNCHRONIZING_ESCM_DATA

MS SQL Could not obtain information about Windows NT group/user 'domain\login', error code 0x5. [SQLSTATE 42000] (Error 15404)

最近碰到一个有趣的错误:海外的一台数据库服务器上某些作业偶尔会报错,报错信息如下所示: ------------------------------------------------------------------------------------------------------------------------------------------------- 日期 2013/9/15 12:00:00 日志 作业历史记录 (JOB_SYNCHRONIZING_ESCM_DATA

Error Code: 500 Internal Server Error.

问题背景: 先前一个网站 www.xxx.com 部署在Windows Server 2008服务器A上,运行了一段时间后,被部署到了CentOS6.3服务器B上,但域名没变,现在遇到一个问题,那些URL中含有中文的链接统统打不开,提示如下错误: Error Code: 500 Internal Server Error. The request was rejected by the HTTP filter. Contact the server administrator. (12217)

Discuz X3.2- 云平台An unknown error occurred. May be DNS Error解决办法

今天在使用云平台的时候出现An unknown error occurred. May be DNS Error 我出错的原因在于启动漫游应用时,有时候问题也会出现在更新站点信息时.    1.解决方案1 刷新一下就好了 2.解决方案2 使用网站创始人帐号登录后台,进入"工具>云平台诊断工具"页面,点击"设置云平台接口IP    3.解决方案3 修改VPS的DNS 修改DNS解析服务 直接修改 vi /etc/resolv.conf 列如我修改为GOOGLE DNS n

VS2015中运行ASPX老项目出错HTTP Error 500.23 - Internal Server Error错误

   今天翻出以前用VS2010做的老项目,在VS2015中运行ASPX页面浏览,出现错误: HTTP Error 500.23 - Internal Server Error 检测到在集成的托管管道模式下不适用的 ASP.NET 设置. 网上搜索了一下解决方法,发现中文的都搜索不到,后来终于在 stackoverflow 中找到了,地址: http://stackoverflow.com/questions/14925383/http-error-500-23-internal-server-

IIS (HTTP Error 500.21 - Internal Server Error)解决

今天在测试网站的时候,在浏览器中输入http://localhost/时,发生如下错误: HTTP Error 500.21 - Internal Server Error Handler "WebServiceHandlerFactory-Integrated" has a bad module "ManagedPipelineHandler" in its module list.       在网上找了一下原因,结果是  原因:在安装Framework v4.

Solve Error: nafxcw.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new[](unsigned int)" (??_U@YAPAXI@Z) already defined in libcpmt.lib(newa

Error: nafxcw.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new[](unsigned int)" (??_U@YAPAXI@Z) already defined in libcpmt.lib(newaop.obj)  Solution: Go to Property -> Linker -> Input -> Additional Dependencies Add nafxcw.l

unexpected error:[] php中的“syntax error, unexpected t

    parse error: syntax error, unexpected t_paamayim_nekudotayim in /home/kafka/test/test.php on line 8paamayim nekudotayim是希伯来语,表示双冒号的意思,也就是double-colon,但却没看到有人提提这个error如何解决.后来总算在官网 http://www.php.net/manual/en/language.oop5.paamayim-nekudotayim.php