Search code examples
laravelredislaravel-queuelaravel-horizon

Laravel horizon: items no longer queued for no obvious reason


I've been running an app on a Laravel forged provisioned server. We have some email jobs that are being queued, and we use Horizon to manage our queues. This has always worked without any issues, but for some reason, we have broken something, and I can't fix it.

This is our setup.

.env

APP_ENV=dev
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
QUEUE_DRIVER=redis

config/queues.php

 return [
   'default' => env('QUEUE_DRIVER', 'sync'),
   'connections' => [
     'sync' => [
       'driver' => 'sync',
     ]
     'redis' => [
       'driver' => 'redis',
       'connection' => 'default',
       'queue' => 'medium',
       'retry_after' => 90,
     ],
  ],
];

config/horizon.php

return [
  'use' => 'default',
  'waits' => [
    'redis:default' => 60,
  ],
  'environments' => [
    'dev' => [
      'high-prio' => [
        'connection' => 'redis',
        'queue' => ['high'],
        'balance' => 'simple',
        'processes' => 10,
        'tries' => 5,
      ],
      'default-prio' => [
        'connection' => 'redis',
        'queue' => ['medium', 'low'],
        'balance' => 'auto',
        'processes' => 10,
        'tries' => 3,
      ],
    ],
  ],
];

I checked the redis-cli info result to make sure the port was right:

forge@denja-dev:~$ redis-cli info
# Server
redis_version:3.2.8
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:11aa79fd2425bed9
redis_mode:standalone
os:Linux 4.4.0-142-generic x86_64
arch_bits:64
multiplexing_api:epoll
gcc_version:5.4.0
process_id:1191
run_id:fcc57fa2c17440ab964538c2d986dc330d9e1223
tcp_port:6379
uptime_in_seconds:3045
uptime_in_days:0
hz:10
lru_clock:13667343
executable:/usr/bin/redis-server
config_file:/etc/redis/redis.conf

When I visit /horizon/dashboard, all is running fine. I was playing a bit with adding some metadata to the payload for queued jobs, at which time the issues began. I then just removed that code again, and basically went back to the previous code base. There is no difference anymore, so I'm now suspecting that I have another issue.

However - I'm not getting ANY exception thrown when I add something to the queue. Bugsnag has no new entries, and my process just continues without any error.

Any idea what I can verify more to detect the actual issue? Is there a problem with the config? I'm a bit lost to be honest, especially since I have no information to work with :(

I also checked using tinker whether I could make a connection to redis, and that too works fine without an exception:

$ php artisan tinker
Psy Shell v0.9.9 (PHP 7.2.0RC3 — cli) by Justin Hileman
>>> Illuminate\Support\Facades\Redis::connection('default')
=> Illuminate\Redis\Connections\PredisConnection {#3369}

Solution

  • The cause of this issue was that the notification that I was testing this with, did use the Queuable trait, but did not implement the ShouldQueue interface. The latter is required to have Laravel automatically queue these Notifications.

    We noticed it when we started testing using other Notifications which went through fine.

    The only question we still had is that we would have expected the email to go out nevertheless, since it would synchronously send it, which for some reason it did not.