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

supervisor/worker stuck after exceptions #19855

Closed
okmkey45 opened this issue Jul 1, 2017 · 2 comments
Closed

supervisor/worker stuck after exceptions #19855

okmkey45 opened this issue Jul 1, 2017 · 2 comments

Comments

@okmkey45
Copy link

okmkey45 commented Jul 1, 2017

This problem occurs to me in two apps

  • Laravel Version: 5.2 / 5.4
  • PHP Version: 7
  • Database Driver & Version: SqlServer / MySql

Description:

Hello. I´ve been having some trouble with supervisor and queues recently. I am using the database driver.

Laravel 5.2 / SqlServer
SHUTDOWN IN PROGRESS
A few months ago, sometimes the database entered in "SHUTDOWN IN PROGRESS" and when the supervisor tried to check the jobs table if any job was waiting to be processed, an exception was thrown. This behavior is expected. But, after the database returned to the usual state, supervisor or the worker continued to getting the same exceptions when it tried to check the jobs table. And because the jobs table is checked continually, this started to throw thousands of errors in a few hours.

Laravel 5.4 / MySql
DEADLOCK FOUND
A few days ago, (other app), that also uses the queues, supervisor and database driver, was having trouble. It seems that supervisor can´t dispatch jobs and insert the data in the jobs table because of the way laravel dispatches jobs. Doing some research, it seems that when I dispatch a job, the jobs table entries in some deadlock and this is an expected behavior (More info about deadlocks here). But when the exception was thrown, its like supervisor or the worker got stuck again and again on any other attempts to dispatch new jobs, this very same exception was thrown.

DIRTY SOLUTION:
For the app with laravel 5,2 I did something dirty. In my app/exceptions/Handler.php, I check every exception that is thrown. If the exception is about "SHUTDOWN IN PROGRESS", Y execute shell_exec with the "sudo service supervisor restart" and supervisor or workers, stopped getting this kind of exception and it everything was fine again and all jobs that was waiting in the table, were processed fine.

For the app with laravel 5,4 I haven´t done anything yet. But it was weird. The deadlock was thrown over and over again everytime I tried to dispatch new jobs. But from a terminal, I ran manually "sudo service supervisor restart" and again, everything was working fine again.

So:

In both cases, the problem was that the supervisor or the worker got stuck in the same exception even when the real cause was overcome.

In both cases, the solution was to restart the supervisor service.

So why the supervisor got stuck in the first exception and stopped working? or is it the worker?
why does the solutions go away when the restarting the supervisor service?

@themsaid
Copy link
Member

themsaid commented Jul 3, 2017

Sorry but please ask on the forums, we keep this repo for bug reporting only, and reading your thread it's more of a question that a bug report.

@themsaid themsaid closed this as completed Jul 3, 2017
@themsaid
Copy link
Member

themsaid commented Jul 3, 2017

One thing to note, the database queue driver is not recommending for an app with many workers, it should be used only in small apps and in-development since there are lots of problems involved with DB connectivity and deadlocks.

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

No branches or pull requests

2 participants