-
Notifications
You must be signed in to change notification settings - Fork 1.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
Handle RecordNotUnique error in find_or_create_all_with_like_by_name correctly #1081
Handle RecordNotUnique error in find_or_create_all_with_like_by_name correctly #1081
Conversation
|
3bffcf8
to
643e676
Compare
This is now ready for a look ! |
643e676
to
e1b18f4
Compare
In the find_or_create_all_with_like_by_name method, instead of issuing a ROLLBACK statement, we wrap the tag creation in a transaction instead. Issuing a ROLLBACK will break nested transactions, and also does not respect multiple databases (available since Rails 6). Adds a spec which attempts to simulate concurrent tag creation. Adds spec option to use truncation database strategy so the spec can see committed records from another thread
e1b18f4
to
3748545
Compare
Hi @seuros - Any feedback on this PR ? |
Could we get the ball rolling on this please @mbleigh @seuros ? When dealing with concurrency or bulk editing this is highly annoying and frankly dangerous as the models are seemingly saved (update/update!/save/save!) when in actuality the data has been rolled back. The taggings however get created. To add to the misery the paper trail audit record gets rolled back too. Thanks |
This is what would fix our data loss I believe as well. Thank you for trying to address it. 👍 |
@jakswa can you try master directly ? if you confirm that it indeed resolve your issue, i will release a a new version. I'm going to clean up the code base. |
@seuros we have been testing it today and so far so good 🤞 usually we'd have a few cases per day crop up |
Still no cases cropping back up 🎉. I'll remember to post back in here if we find any problems with this changeset, but going into the weekend feeling good! Thank you again! |
Related to #1068, #948
In the find_or_create_all_with_like_by_name method,
instead of issuing a ROLLBACK statement, we wrap the tag creation in a
transaction instead.
Issuing a ROLLBACK will break nested transactions, and also does not
respect multiple databases (available since Rails 6).
Adds a spec which attempts to simulate concurrent tag creation