Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

queue:worker fails with Server has gone away error on MariaDB #51229

Closed
cloudenum opened this issue Apr 28, 2024 · 4 comments
Closed

queue:worker fails with Server has gone away error on MariaDB #51229

cloudenum opened this issue Apr 28, 2024 · 4 comments

Comments

@cloudenum
Copy link

Laravel Version

10.48.9

PHP Version

8.2.13

Database Driver & Version

MariaDB 10.6.16 for Linux (x86_64)

Description

When the database connection that used by queue worker is closed then it throws an exception, it won't detect the exception as connection related error. So, the queue worker won't retry to reconnect the database connection.

[2024-04-28 03:33:22] production.ERROR: SQLSTATE[HY000]: General error: 2006 Server has gone away (Connection: mysql, SQL: QUERY) {"exception":"[object] (Illuminate\\Database\\QueryException(code: HY000): SQLSTATE[HY000]: General error: 2006 Server has gone away (Connection: mysql, SQL: QUERY) at /home/u12345678/project/vendor/laravel/framework/src/Illuminate/Database/Connection.php:829)
...

After looking at the code at src/Illuminate/Database/DetectsLostConnections.php
It appears that the method causedByLostConnection doesn't ignore the error message case, and my shared hosting server report the error as Server has gone away with an uppercase S instead of the usual server has gone away with a lowercase s.
Thus, it won't detect it as a connection lost and just throws the exception again.

The error message might be specific to MariaDB as I look into MariaDB source code at errmsg.c , it's indeed that MariaDB use different client error messages to MySQL.

Note: In the log above, I have replaced the query and username with a placeholder for security reason.

Steps To Reproduce

  1. Start queue:worker
  2. Wait until connection closed.
  3. The queue worker will fail to detect the connection exception and throws it instead.
@driesvints
Copy link
Member

Thank you. Can you perhaps send in a PR to add the uppercase S version?

Copy link

Thank you for reporting this issue!

As Laravel is an open source project, we rely on the community to help us diagnose and fix issues as it is not possible to research and fix every issue reported to us via GitHub.

If possible, please make a pull request fixing the issue you have described, along with corresponding tests. All pull requests are promptly reviewed by the Laravel team.

Thank you!

@cloudenum
Copy link
Author

I see that @Jubeki has made a PR and has been merged, should I close this issue?

@driesvints
Copy link
Member

Yeah this is gonna be in next release. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants