easyswoole icon indicating copy to clipboard operation
easyswoole copied to clipboard

队列里数据库问题

Open laumin opened this issue 2 years ago • 1 comments

在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

请问这是什么原因呢

laumin avatar Aug 16 '22 07:08 laumin

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

XueSiLf avatar Aug 18 '22 09:08 XueSiLf

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

XueSiLf avatar Mar 15 '24 12:03 XueSiLf