laravel / lumen-framework

The Laravel Lumen Framework.
https://lumen.laravel.com
MIT License
1.48k stars 420 forks source link

Lumen Queue Issue #604

Closed milon closed 5 years ago

milon commented 7 years ago

Description:

I am using lumen 5.2(because I have use php 5.5, the library I am using for connecting to SMPP works on 5.5) for an SMS sending server. I have 4 different queue priority, highest, high, default and low. I am using Redis as my queue driver.

Whenever a user requested for sending an SMS, it sends a Job to the queue based on priority. The job is really simple, just open a SMPP connection and send the SMS, then close the connection.

I am running the queue listener with supervisor. Here is the config of supervisor-

[program:send-sms]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/html/artisan queue:listen redis --tries=0 --queue=highest,high,default,low
autostart=true
autorestart=true
numprocs=6
redirect_stderr=true
stdout_logfile=/var/log/supervisor/send_sms.log

The system working fine for most of the time, but sometimes it stops dispatching job from queue. In the error log, I found this-

[2017-04-12 17:40:16] lumen.ERROR: exception 'ErrorException' with message 'Undefined index: job' in /var/www/html/vendor
/illuminate/queue/Jobs/Job.php:126
Stack trace:
#0 /var/www/html/vendor/illuminate/queue/Jobs/Job.php(126): Laravel\Lumen\Application->Laravel\Lumen\Concerns\{closure}(8
, 'Undefined index...', '/var/www/html/v...', 126, Array)
#1 /var/www/html/vendor/illuminate/queue/Jobs/RedisJob.php(50): Illuminate\Queue\Jobs\Job->resolveAndFire(Array)
#2 /var/www/html/vendor/illuminate/queue/Worker.php(213): Illuminate\Queue\Jobs\RedisJob->fire()
#3 /var/www/html/vendor/illuminate/queue/Worker.php(157): Illuminate\Queue\Worker->process('redis', Object(Illuminate\Que
ue\Jobs\RedisJob), '0', '0')
#4 /var/www/html/vendor/illuminate/queue/Console/WorkCommand.php(126): Illuminate\Queue\Worker->pop('redis', 'highest,hig
h,de...', '0', '3', '0')
#5 /var/www/html/vendor/illuminate/queue/Console/WorkCommand.php(79): Illuminate\Queue\Console\WorkCommand->runWorker('re
dis', 'highest,high,de...', '0', '128', false)
#6 [internal function]: Illuminate\Queue\Console\WorkCommand->fire()

I searched with the error, and found out this thread- https://github.com/laravel/framework/issues/9555.

Then I log into redis console and after running KEYS *, I found a new key called queues:highest:delayed and if I delete it with with DEL command, then the queue started working fine agian. From where It comes. I don't use any delay() dispatch option anywhere in my code.

I also checked what this key contains. It's a sorted set and it contains value something like this-

{"id": "183428934728746524875623", "delay": 159}

So, it is failing while processing the job. From where this value comes from? How can I get rid of this?

laurencei commented 7 years ago

Not sure if related - but you said:

I have 4 different queue priority, highest, high, default and low

But your supervisor config is

--queue=high,default,low

So you are not even processing the highest queue tube? It should be:

--queue=highest,high,default,low

milon commented 7 years ago

@laurencei, oww sorry. that was a typo. The config is actually-

--queue=highest,high,default,low
driesvints commented 5 years ago

Closing this issue because it's already solved, old or not relevant anymore. Feel free to reply if you're still experiencing this issue.