mikemand's avatar

Redis Queue "delayed" jobs not being run

Hello,

I have an old Laravel 5.4 app that was running a Redis queue just fine until I decided to try and mess with it. I have Horizon running on a different app on the same server, so I thought I'd try and see if I could get Horizon to manage the 5.4 app's queue too. Needless to say, it didn't work.

My 5.4 app has 308 "delayed" jobs (I say delayed because they are queued but have not run, even after switching on my queue listener again), and nothing I do seems to make them run. Does anyone know what I can do to trigger the queue to run them? I have tried everything I can think of, from artisan queue:listen to artisan queue:work --queue=default and artisan queue:retry all

I use Laravel Forge and my Queue Worker is set up like so:

| Connection | Queue | Timeout | Processes | Tries | Daemon |
|-----------------|------------|-------------|-----------------|---------|------------|
| redis | default | 60 | 1 | 3 | Yes |

Here's the output of some commands using Tinker:

>>> Redis::llen('queues:default');
=> 308
>>> Redis::lrange('queues:default', 0, -1);
=> [
     "{"displayName":"Modules\Lesson\Mail\Parties\Customer\ApprovedMessage","job":"Illuminate\Queue\CallQueuedHandler@call","maxTries":null,"timeout":null,"data":{"commandName":"Illuminate\Mail\SendQueuedMailable","command":"O:34:\"Illuminate\Mail\SendQueuedMailable\":3:{s:8:\"mailable\";O:52:\"Modules\Lesson\Mail\Parties\Customer\ApprovedMessage\":17:{s:3:\"mes\";O:45:\"Illuminate\Contracts\Database\ModelIdentifier\":2:{s:5:\"class\";s:29:\"Modules\Lesson\Entities\Party\";s:2:\"id\";i:488;}s:4:\"from\";a:0:{}s:2:\"to\";a:1:{i:0;a:2:{s:4:\"name\";N;s:7:\"address\";s:24:\"<redacted>\";}}s:2:\"cc\";a:0:{}s:3:\"bcc\";a:0:{}s:7:\"replyTo\";a:0:{}s:7:\"subject\";N;s:11:\"\u0000*\u0000markdown\";N;s:4:\"view\";N;s:8:\"textView\";N;s:8:\"viewData\";a:0:{}s:11:\"attachments\";a:0:{}s:14:\"rawAttachments\";a:0:{}s:9:\"callbacks\";a:0:{}s:10:\"connection\";N;s:5:\"queue\";N;s:5:\"delay\";N;}s:5:\"tries\";N;s:7:\"timeout\";N;}"},"id":"bZOqJGw5tykWTR6ZcW8JTEz3aAYy26nP","attempts":0}",
     "{"displayName":"Modules\Lesson\Mail\Parties\Customer\GalleryMessage","job":"Illuminate\Queue\CallQueuedHandler@call","maxTries":null,"timeout":null,"data":{"commandName":"Illuminate\Mail\SendQueuedMailable","command":"O:34:\"Illuminate\Mail\SendQueuedMailable\":3:{s:8:\"mailable\";O:51:\"Modules\Lesson\Mail\Parties\Customer\GalleryMessage\":18:{s:3:\"mes\";O:45:\"Illuminate\Contracts\Database\ModelIdentifier\":2:{s:5:\"class\";s:29:\"Modules\Lesson\Entities\Party\";s:2:\"id\";i:488;}s:5:\"token\";O:45:\"Illuminate\Contracts\Database\ModelIdentifier\":2:{s:5:\"class\";s:28:\"Modules\Art\Entities\Gallery\";s:2:\"id\";i:579;}s:4:\"from\";a:0:{}s:2:\"to\";a:1:{i:0;a:2:{s:4:\"name\";N;s:7:\"address\";s:24:\"<redacted>\";}}s:2:\"cc\";a:0:{}s:3:\"bcc\";a:0:{}s:7:\"replyTo\";a:0:{}s:7:\"subject\";N;s:11:\"\u0000*\u0000markdown\";N;s:4:\"view\";N;s:8:\"textView\";N;s:8:\"viewData\";a:0:{}s:11:\"attachments\";a:0:{}s:14:\"rawAttachments\";a:0:{}s:9:\"callbacks\";a:0:{}s:10:\"connection\";N;s:5:\"queue\";N;s:5:\"delay\";N;}s:5:\"tries\";N;s:7:\"timeout\";N;}"},"id":"xKRehjPR4BjUjIyZH7txNeRnAAdTLZqP","attempts":0}",
...many more queued jobs...
]
>>> Redis::zcount('queues:default:delayed', '-inf', '+inf');
=> 8
>>> Redis::zcount('queues:default:reserved', '-inf', '+inf');
=> 0
0 likes
2 replies
mikemand's avatar

I'm not sure what I did exactly to fix it, but I renamed my queue from default to something else (deleted my Forge worker and added it with the new name), then exported all of the queue:default key from Redis an reimported it with the new name (find queue:default in the export and replace it with queue:newname).

Queues are running again and all the backed up jobs are running.

As a side note, it seems like my queue sped up when I did this...Wait times went from like 1-2 seconds to under 100 ms.

1 like
JWprogrammer's avatar

Yes, you need to change the name of the queue to something else.

For example.

In queue.php config file:

'redis' => [
    'queue' => env('REDIS_QUEUE', 'queue')
]

In .env:

REDIS_QUEUE=queue

Start command:

php artisan queue:work --queue=queue
1 like

Please or to participate in this conversation.