Documentation surrounding Queued unique jobs and logic #47852
Unanswered
joelharkes
asked this question in
Q&A
Replies: 1 comment 1 reply
-
The database lock expiry of 1 day is been there since the start, this i think makes it confusing to use locks in combination with database Caching: b78880a |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This is as far as i understand the jobs processing works in combination with locks. Can anyone validate what i wrote is correct?
Jobs can be made unique by:
Locks are set when job is put on the queue via
PendingDispatch
, which is not done when you manually call (dispatcher::class)->dispatch()!. but is done calling thedispatch($job)
helper function.Lock releases are done in
CallQueuedHandler
.Both if job fails (exception thrown, with still some retries to go) or is released manually within the job, the lock is not removed, but also not reset!
Catches
So the catches are the following:
PendingDispatch
class otherwise locks are not set.ShouldBeUniqueUntilProcessing
, lock is removed before processing, no matter if the job fails afterwards.$this->seconds > 0 ? time() + $this->seconds : Carbon::now()->addDays(1)->getTimestamp();
Retry attemps
the attemps are increased when the job is popped from the queue. (always 1 for non queued jobs)
Worker
class will check the maximum amount of retries (set on job or default set when running queue:work job) and throw anMaxAttemptsExceededException
when ran out of attemptsqueue:retry
the attempts are reset to 0.Beta Was this translation helpful? Give feedback.
All reactions