Support the ongoing development of Laravel.io →
posted 3 years ago
Last updated 2 years ago.
0

Also some logs from Horizon:

First job:

{ uniqueFor: 3600, timeout: 3600, id: 86, job: null, connection: null, queue: "delivery:push-manual-campaign-to-personalize", chainConnection: null, chainQueue: null, chainCatchCallbacks: null, delay: null, afterCommit: null, middleware: [ ], chained: [ ] }

Second job:

{ uniqueFor: 3600, id: 86, job: null, connection: null, queue: "delivery:push-manual-campaign-to-personalize", chainConnection: null, chainQueue: null, chainCatchCallbacks: null, delay: null, afterCommit: null, middleware: [ ], chained: [ ] }

I see the difference that the second job has no timeout

0

Have you implemented Illuminate\Contracts\Queue\ShouldBeUnique to your job? Like this:

use Illuminate\Contracts\Queue\ShouldBeUnique;

class UpdateSearchIndex implements ShouldQueue, ShouldBeUnique
{
  // ...
}

Remind that any other job will be dispatched if the previous one is completed, so did you check timestamps of your jobs?

So, any new dispatches of the job with the same product ID will be ignored until the existing job has completed processing. In addition, if the existing job is not processed within one hour, the unique lock will be released and another job with the same unique key can be dispatched to the queue.

0

@Theraloss

Thanks for the answer!

Yes, I did that. However, I noticed that my CACHE_DRIVER was set to file. Docs says that the 'File' driver also supports atomic locking, but I think it could be something regarding that. Do you think that might be the reason?

Also, I'm aware that a job can be dispatched after it gets completed, but this wasn't the case as far as I can remember. The biggest problem is that it's hard to replicate. I switched to Redis, it didn't happen again, but we'll see.

Anyway, I think I'll add something like this as an additional layer of protection.

$lock = Cache::lock('some-unique-id' 900);

if (!$lock->get()) {
    return;
}

This is important to me because it can produce additional costs too. It's about sending emails and SMS.

Last updated 3 years ago.

theraloss liked this reply

1

Honestly I don't know if there are issues with File driver, glad that Redis solves it (apparently) :)

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Nedim nedim Joined 11 Sep 2020

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.