-
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
Race Condition: dispatch() saves uncommitted models to async queue #29710
Comments
It's just a coincidence, but I updated it with a comment about a package which supports "transactional events", please see laravel/ideas#1441 (comment) Here's btw an older issue talking about this problem: #8627 (there are likely more) |
I think it's best that we stick this with the ideas issue. Feel free to submit a pr if you think this can be improved. |
Hello everyone, based on an existing package and with permission of its original author, I've drafted a possible solution to tackle the "transactional events" problem. At the moment it's a draft PR in my Laravel forked repo to first gather feedback from the community before approaching to create an official PR, to give things time to unfold / develop. I invite everyone to participate in mfn#1 and share your feedback. Thank you! |
Description:
Job handler (horizon for example) throws ModelNotFoundException.
Because serialized models was recently created in parallel process but still don't commited (it's not about rollback).
Steps To Reproduce:
Create listener for
saved
(or another) model event with:I see the simplest solution -
dispatch()
should throw an exception if the models are not commited.Also implement something like
dispatch_on_commit()
which will dispatch only after a successful commit of the models necessary for serializing the job.See also: laravel/ideas#1441
The text was updated successfully, but these errors were encountered: