Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent 500 on parallel service instance creation (cloudfoundry#3899)
We observed 500 responses on POST /v3/service_instances when requests run in parallel and the db is small. This occurs if the one 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. This leads to a PG::UniqueViolation: ERROR: duplicate key value violates unique constraint which is not catched and thus results in a 500 response. To prevent this, we add a Sequel::UniqueConstraintViolation rescue to catch the PG::UniqueViolation error and to return an adequate 422 error "The service instance name is taken.."
- Loading branch information