Closed zhang988925 closed 6 years ago
我们有3个类型的应用 全部被此问题困扰无解 每次都需要重复服务,还请各位给个正确的方法或者告知深层原因
MySQL根据配置文件会限制Server接受的数据包大小。有时候大的插入和更新会受 max_allowed_packet 参数限制,导致写入或者更新失败 改一下 max_allowed_packet 配置
https://wiki.swoole.com/wiki/page/325.html 所以在多个进程之间,一定不能共用连接
@zhang988925 不知道你解决没有? 我这边遇到了类似的问题并解决了 虽然我没有用过Yii不知道你是否可以参考:
在我们的框架中以PDO为例 由于swoole是守护进程 实际上每个请求都用的同一个sql连接 传统的fpm模式会在fpm进程结束后会自己进行销毁,PDO据说会在析构的自己去释放链接 但是守护进程不会有这一步 就会导致php这边连接以为存在 但是MYSQL自己的链接超时进行了销毁 再有请求进入的时候,php误认为链接存在仍然去进行操作 就会报错 不知道对你有没有参考价值……
我找了问题的根源,是因为mysql长连接,一直发送数据,时间长了,数据量就会增加,触发mysql单个连接最大发送数据,修正方案,长连接一定时间关闭一次,或者定时重启swoole进程
Please answer these questions before submitting your issue. Thanks!
Yii2 console 投放任务,连接数据库(模型)处理数据
我找遍了百度和谷歌上的各种问答 都无法解决问题
What did you see instead?
What version of Swoole are you using (
php --ri swoole
)? 1.9.21What is your machine environment used (including version of kernel & php & gcc) ? CentOS Linux release 7.4.1708 (Core)