My app is dispatching a job, it was working, but there's one job that doesn't get dispatch because there's an error on redis, but this is just one job out of thousands.
RedisClusterException: Error processing response from Redis node!
I'm dispatching the job via this way:
HereTheJob::dispatch($this);
Here's my setup Queue: SQS Cache: redis
I think its using cache here because my job has ShouldBeUnique
, its saving the unique job on cache.
So my question is, when there's an error on redis, how do I retry to dispatch the job?
Yes, by default, it uses whatever
cache store
is configured. If it’s Redis, it will hit Redis to check/create that lock before adding the job to the queue.
RedisClusterException
or connection error
at that point, the dispatch will fail because it can’t check or create the lock.You can wrap your job dispatch logic within retry()
helper. It will try to dispatch job upto attempt limits. When job will not throw error it won't try further.
retry(3, function () {
HereTheJob::dispatch($this);
}, 1000);
If your Redis cluster has occasional instability and it's only for job uniqueness, consider using database or a single-node Redis instance for unique_job_cache using uniqueVia()
method within your job class:
public function uniqueVia(): Repository
{
return Cache::driver('database');
}