easy-swoole / easyswoole

swoole,easyswoole,swoole framework
https://www.easyswoole.com/
Apache License 2.0
4.74k stars 511 forks source link

队列里数据库问题 #558

Closed laumin closed 6 months ago

laumin commented 2 years ago

在redis 的队列了经常会出现

message":"SQLSTATE[HY000] [2002] Connection reset by peer or Transport endpoint is not connected [show full columns from out_order_bill_log]

SQLSTATE[HY000] [4031] The client was disconnected by the server because of inactivity. See wait_timeout and interactive_timeout for configuring this behavior

数据库配置如下:

'host' => '', 'port' => 3306, 'user' => 'xxxx', 'password' => 'xxxx', 'database' => 'xxxx', 'timeout' => 9, 'charset' => 'utf8mb4', 'fetchModel' => true, 'returnCollection' => true, 'strictType' => true, 'minObjectNum' => 15, 'intervalCheckTime' => 3580, 'maxObjectNum' => 120, 'maxIdleTime' => 15, 'autoPing' => 5,

msyql8.3

wait_timeout配置为 28800

eayswoole版本为 3.4.4 swoole版本为 4.6.7

请问这是什么原因呢

XueSiLf commented 2 years ago

您好,请您在进行redis操作后加上这句代码 \Co::sleep(0.01); 让redis连接对象回到redis连接池,您可以试试

XueSiLf commented 6 months ago

你需要将在队列中的模型相关操作全部换成invoke的方式进行调用,才能避免这种情况。