-
Notifications
You must be signed in to change notification settings - Fork 363
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
Prevent 500 on parallel object creation #3918
Conversation
9c76c97
to
b636892
Compare
While fixing #3899, we found further possible occurrences of 500 errors in severel _create actions when doing parallel requests. In this PR we want to address them by adding an around_save to the corresponding model in which we catch Sequel::UniqueConstraintViolation errors for the case when ne POST bypasses the other one and inserts the record into the db after the first POST has passed the validate function but before the actual insert.
d5e3683
to
fea4efb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Just a question about mocking in two tests and a minor finding.
EDIT: Also do we plan to get rid of the unique checks in the coding? If we catch the unique constraint errors thrown by the DB reliably now, it should not be necessary to check for uniqueness beforehand.
spec/unit/actions/service_credential_binding_app_create_spec.rb
Outdated
Show resolved
Hide resolved
spec/unit/actions/service_credential_binding_app_create_spec.rb
Outdated
Show resolved
Hide resolved
spec/unit/actions/service_credential_binding_app_create_spec.rb
Outdated
Show resolved
Hide resolved
spec/unit/actions/service_credential_binding_app_create_spec.rb
Outdated
Show resolved
Hide resolved
spec/unit/actions/service_credential_binding_key_create_spec.rb
Outdated
Show resolved
Hide resolved
Changes in cloud_controller_ng: - Prevent 500 on parallel object creation PR: cloudfoundry/cloud_controller_ng#3918 Author: kathap <[email protected]>
While fixing #3899, we found further possible occurrences of 500 errors in severel _create actions when doing parallel requests. In this PR we want to address them by adding an around_save to the corresponding model in which we catch Sequel::UniqueConstraintViolation errors for the case when ne POST bypasses the other one and inserts the record into the db after the first POST has passed the validate function but before the actual insert.
A short explanation of the proposed change:
Adding an around_save to the corresponding model in which we catch Sequel::UniqueConstraintViolation errors for the case when ne POST bypasses the other one and inserts the record into the db after the first POST has passed the validate function but before the actual insert
An explanation of the use cases your change solves
No more 500 errors on parallel request execution
Links to any other associated PRs
Prevent 500 on parallel service instance creation #3899
Prevent 500 on parallel org quota creation #3924
I have reviewed the contributing guide
I have viewed, signed, and submitted the Contributor License Agreement
I have made this pull request to the
main
branchI have run all the unit tests using
bundle exec rake
I have run CF Acceptance Tests