Search code examples
laravelqueuebeanstalkd

JOB_ID NOT FOUND exception Beanstalkd in PHP using pda/pheanstalk in Laravel 4.2


I have a queuing system with my workers written in Laravel 4.2. I am getting a JOB_ID not found exception whenever artisan tries to get the next ready job in queue.

Investigating I noticed the following:

If the next ready Job has ID = 74, when I run artisan queue:work, it tries to pick up the next ready Job with ID 73 instead of 74 resulting in the JOB_ID not found exception.

I have restarted beanstalkd several time but issue persist. I have also checked the TTR for each job and set it to 3600 but still no luck.

Anyone experienced this before? Drilling down the Beanstalk PDA library, i noticed this happens when the ReleaseCommand class calls its dispatch method.

Anyone experienced this? What could possibly cause this? Thanks in advance.


Solution

  • Without proper code and even with code it's difficult to locate such a problem. But we had in past, and I can explain how should work, and when would that Exception gets thrown.

    So the worker, does a reserve for a job, and holds until it does it's work, or the beanstalkd server takes it back.

    1. If you see job Id 74, and when you run it, and you see it's picking up job id 73, you need to make sure there are no urgent jobs, as that is different from ready state jobs.
    2. The worker after it's done wants to delete the job. But can do only if he still holds the reserve. If the worker doesn't hold the reserve it means the job was retracted by the beanstalkd server or the release was done too soon by the worker itself. There is a default 60 second for TTR, time to resolve, after that Beanstalkd takes back the job from your worker, hence cannot delete it. These situations need to be located in your code.
    3. Use the wonderful admin console panel, to help you see the state of the jobs and help you in development https://github.com/ptrofimov/beanstalk_console