-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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 daemon loses connection when unserializing model #10604
Comments
I have a worker that does nothing but process a single, very heavy job that runs once every 24hours. I believe the default 8hr I plan to raise the |
Problem is the error occurs before it gets to any application code so you don't get a chance to reconnect without overloading a framework method, which seems a bit wrong, especially since the method isn't even inside the Job but inside the Model Maybe I'm being really stupid and missing something obvious |
@GrahamCampbell sorry, what am I misunderstanding then? |
We already will reconnect under the hood if the query fails. |
Oh, I see. |
Is |
Let me know if #10609 fixes you problem. Please comment on the PR though rather than this issue since I don't read comments on closed issues. |
Hi @GrahamCampbell can you please do this patch for 5.0 branch also as I am experiencing similar issue. I hope that could fix my problem. Current details are -- It happens in case of longer running jobs a few times. Thanks, |
This only seems to happen when using MariaDB and the mysqlnd driver
When the queue worker is running in daemon mode and it takes a job from the queue which has a model passed into the constructor the following error occurs
As you can see, this is happening inside Laravel's automatic call to findOrFail when getting a job from the queue
Adding the following to the model seems to fix it
but from what I can see, Laravel is supposed to try and reconnect automatically, and does appear to with the normal mysql server
You can see this in action by cloning this repo
https://github.com/REBELinBLUE/laravel-queue-test
running
vagrant up && vagrant ssh
(it uses laravel/homestead) then in the vmsudo /vagrant/provision/provision.sh
to remove MySQL and install maria, run the migrations and start the queue worker etcthen start tailing the log
tail -f /var/www/test/storage/logs/laravel.log
Leave it running for a while and visit http://192.168.10.200/ to add a Post model to the queue, you can see beanstalk console at http://192.168.10.200:81/
You will eventually see this error in the log. Obviously by default the DB has a wait_timeout of an hour and default interactive_timeout of several hours so you will want to edit
/etc/mysql/my.cnf
and set them quite low (I used 30 seconds in my testing). Restart mysql and queue listenerservice restart mysql
andservice restart supervisor
.Wait until the time limit and then visit the URL to add the queue to the job
Hope that explains it clear enough
The text was updated successfully, but these errors were encountered: