laravel / framework

The Laravel Framework.
https://laravel.com
MIT License
32.52k stars 11.02k forks source link

2006 MySQL server has gone away in queue:work scenario #51894

Closed TaylorChen closed 4 months ago

TaylorChen commented 4 months ago

Laravel Version

10.4.1

PHP Version

8.1.4

Database Driver & Version

mysql 8.0

Description

In MySQL configuration, there is a parameter called "wait_timeout", this parameter means roughly like this: when a client connects to MySQL database, if the client doesn't disconnect itself and doesn't do any operation, MySQL database will keep this connection "wait_timeout" for such a long time (in s, default is 28800s, i.e. 8 hours). (unit is s, default is 28800s, that is, 8 hours), after this time, MySQL database will disconnect the connection in order to save resources; of course, during this process, if the client has any operation on this connection, MySQL database will start calculating this time again. Yesterday, I used supervisor to do process management for queues, using queue:work, and a question came to mind: queue:work runs all the time, so if there are no tasks for a long period of time, does it send a timeout to the database connection? In the current scenario, I found that the error "2006 MySQL server has gone away" appears occasionally, but it is normal to check the database, I am currently using version 10.x, and after checking the source code, I found that there is a way to recheck whether the database has been connected, but I found that it does not work. What is the problem?

Steps To Reproduce

in queue scenario

iBotPeaches commented 4 months ago

The queue system will detect lost connections and remake it - this isn't a bug report btw.