framework icon indicating copy to clipboard operation
framework copied to clipboard

数据库开启断线重新后还是会报错:PDO::beginTransaction(): send of 22 bytes failed with errno=110 Connection timed out

Open zhoushi1 opened this issue 3 years ago • 1 comments

php:>=7.2 topthink/framework:5.1.39 topthink/think-queue:2.0.4

在队列场景下,经常会报错:PDO::beginTransaction(): send of 22 bytes failed with errno=110 Connection timed out 不过数据库配置我开启断线重连了,还是会报这个错误! 有什么解决方案吗!

zhoushi1 avatar Jun 15 '21 04:06 zhoushi1

我们项目也遇到了

数据库那个配置比较鸡肋的,是根据一些写死的标识值来判断的(当然这些标识在框架升级会做更改):

https://github.com/top-think/think-orm/blob/fed6308912982320fe57cf62ceef2ca69fbb796a/src/db/PDOConnection.php#L165

总的来说还是达不到预期,我们采用了另外的方案: 1、队列开始消费入口每次都强制重连,connect('db',true),结束消费时断开连接(针对量不大的场景) 2、采用supervisor管理队列,服务器上定时reload(1小时reload一次)

kingfer30 avatar Jul 20 '21 03:07 kingfer30