-
Notifications
You must be signed in to change notification settings - Fork 11.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Batched Unique Jobs Can Be Dispatched With The Same UniqueId Values #48882
Comments
Hey there, Unfortunately we don't support this version of the library anymore. Please check out our support policy on which versions we are currently supporting. Can you please try to upgrade to the latest version and see if your problem persists? If so, please open up a new issue and we'll help you out. Thanks! |
Issue is always present in latest version (10.8). When dispatching 2 batches with same job in each, both jobs are executed concurently.
Worker 1: Worker 2: |
I am facing this behavior with |
Laravel Version
9.19
PHP Version
8.0.2
Database Driver & Version
MariaDB 10.5.19
Description
I've come across this interesting scenario that may potentially be a bug, we have a
ShouldBeUnique
Job that is kicked off in two scenarios:This job uses the interface via the
uniqueId()
function outlined in the documentation and works great in the first scenario, spamming that endpoint with the same "unique" value we've determined does not allow multiples of that same job to be put into queue. As is intended.The second scenario however has brought up the issue where that "batched unique jobs" seemingly are ignoring the
uniqueId()
returned value?This was noticed when a job with the
uniqueId()
value of '1' was dispatched from the batched jobs and then from the endpoint, resulting in two "Unique Jobs" with the sameuniqueId()
being processed.Messing with it I've been unable to determine why this is the case until I had the thought of just putting multiple "unique jobs" with the same
uniqueId()
into a single batch. Every job ends up being queued and processed concurrently even with the sameuniqueId()
returned value.I'm able to confirm this in Horizon showing the same batch id for each job, the same property that is used in the
![image](https://private-user-images.githubusercontent.com/132939222/279773034-db0d5770-4f2b-47c2-9073-caed9131ee6d.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxNjE4MzUsIm5iZiI6MTczOTE2MTUzNSwicGF0aCI6Ii8xMzI5MzkyMjIvMjc5NzczMDM0LWRiMGQ1NzcwLTR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ZGQ5OTA4ZjliZWYxYjlmZjYxZWY4OWUwYzU5NTQ2OWY4OGVkJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.CZDjyYz7FOCVINCJdrzMpw-4MjHNhnFNeolIXKGv550)
uniqueId()
function and different job ids for each job. Below are two of the jobs with the same value, I've cut off type names for privacy:Here's the "slightly edited for privacy" code that performed the above problem.
Class that is the job that performs the "bulk batch" dispatching causing the problem:
Controller Endpoint With Single Function that performs the one off dispatch:
Unique Job Class code:
Sorry to be reporting this outside of the bug fix window for this version of Laravel. Again I'm uncertain if this is a bug or intended behavior, we just need insight on it.
Steps To Reproduce
Unfortunately I'm unable to share the code directly with a branch of a github repository for ease of replication.
In general I'd assume that quickly copying my code from the description and using both avenues in however you see fit would replicate the problem.
If not please let me know what I can provide to further assist.
The text was updated successfully, but these errors were encountered: