framework: ErrorException: Warning: Error while sending STMT_PREPARE packet
- Laravel Version: Laravel Framework Lumen (5.8.8) (Laravel Components 5.8.*)
- PHP Version: PHP 7.2.19-0ubuntu0.18.04.1
- Database Driver & Version: mysql Ver 14.14 Distrib 5.7.26
Description:
Queue jobs is losing connection to database and throw exception ErrorException: Warning: Error while sending STMT_PREPARE packet
Queue command (managed by supervisord) artisan queue:work --queue=children --sleep=3 --tries=3 --daemon
The error is not related to large data sent to database, it seems to be it’s related to some how data connection is lost with database
My error comes from a simple query
$child = Child::find($child_id);
Let me know if you need any further information
PS: No change in mysql nor php default settings.
Steps To Reproduce:
Sometime below steps will work 1- Make sure queue is running 2- Restart database (/etc/init.d/mysql restart) 3- Send a job to the queue 4- You will get this error 5- Send another job to the queue (no error)
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 4
- Comments: 61 (20 by maintainers)
As replied by a dev from Sentry in the sentry-laravel issue
Getting the same issue. Never had this issue on Laravel 5.6 but after updating to 5.7 this now happens daily. It looks like jobs are not actually failing since I have no items in the failed_jobs table, yet Sentry reports 80 issues. We are working with MySQL so not mariadb related
All these issues seem to be related:
I continue obtaining the error even though apply the code from last comment
I ended up adding this method to Exceptions/Handler.php:
I’m with @Christophvh on the question about Sentry.
The error itself is pretty normal for long running jobs, but it supposed to be caught by the framework and transformed to a QueryException (which in turn triggers the re-connection to the database), so it should never reach Sentry in its native form. But it does. (Maybe even before the framework catches and handles it? That would explain why there’s no failed jobs)
So the question remains: do we all use Sentry?
I do:
"sentry/sentry-laravel": "^1.0.0",
And also updated it to 1.0 the same time we did the 5.8 update.Many users are reporting similar experiences on Laracasts
https://laracasts.com/discuss/channels/laravel/error-while-sending-stmt-prepare-packet-on-queued-jobs
@mrahmadt What happens if the error message does NOT contain ‘STMT_PREPARE packet’?
In your case it’s undefined / not explicit, so I rewrote your code as follows:
I’m going to close this as this seems to be Sentry specific and there really isn’t an issue except from the warning. Thanks to everyone who helped investigate this 👍
I have had it with 1 and also with 40, so i don’t think it has anything to do with the amount of workers
@markdza @Mult1Hunter you can find the issue here https://github.com/getsentry/sentry-laravel/issues/254#issuecomment-512715265 seems like nothing to do with laravel itself.
I do use Sentry. And I don’t recall seeing the issue reported in HoneyBadger, which I also use.
Just got hit with one today 😦 @koenhoeijmakers is right. The error has nothing to do with the amount of workers. Sentry says it failed making a request to grab user_settings from MYSQL during a job call.
ErrorException: Warning: Error while sending STMT_PREPARE packet. PID=27771 ErrorException: Warning: PDO::prepare(): MySQL server has gone away.
What we do know:
I too am facing this issue. I am not using horizon or telescope. I do not have any jobs that are shown as failed in my DB but I do get the notifications a few times a day. It fails randomly on any job in the program. I have very little traffic on the server. I have been trying to figure it out for the past few days now.
I only receive the “Error while sending STMT_PREPARE packet. PID=*” I have not received the “MYSQL server has gone away.”
Laravel 5.8.28 MYSQL version: 5.7.26
The server is deployed using forge. My worker settings: connection = redis queue = default timeout = 0 processes = 1 tries = 3
I am going to bump up the processes number and see if that helps and then I’ll report back
I do not use telescope so i don’t think the problem lies there, no transactions too
Im not using horizon nor telescope and face this issue
I’m passing Eloquent model to the queued job constructor, maybe this is the issue
Any one doing the same thing ?
On Fri, Jul 12, 2019 at 17:38 jlmmns notifications@github.com wrote:
– echo “Hello World 😃”
@driesvints 3 separate listeners are failing in our application and none of them have database-transactions. It might indeed be a horizon update, we started to notice it after a composer update. We don’t use telescope so horizon seems most likely.
Same issue from April 28: https://github.com/laravel/horizon/issues/583
Also in stackoverflow
And most of the cases its laravel not lumen
On Sun, Jun 30, 2019 at 13:25 decowboy notifications@github.com wrote:
– echo “Hello World 😃”