Skip to content

Conversation

johha
Copy link
Contributor

@johha johha commented Oct 16, 2025

Adds an ignored_unique_constraint_violation_errors option to the many_to_many association in the VcapRelations Sequel plugin. When this option is provided with a list of index name patterns, any Sequel::UniqueConstraintViolation error that occurs during an add_ operation on an association and matches one of the patterns will be caught. The operation is wrapped in a transaction with a savepoint, which is rolled back upon catching the specific error, effectively making the addition idempotent. This prevents race conditions where concurrent requests attempt to add the same association. This issue can be observed when a user makes two POST requests at the same time to create a new resource instance.

This new option is applied to the staging_spaces relationship in the SecurityGroup` model to handle potential concurrent updates. Further models will updated in separate commits.

  • 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 branch

  • I have run all the unit tests using bundle exec rake

  • I have run CF Acceptance Tests

Adds an `ignored_unique_constraint_violation_errors` option to the many_to_many association in the `VcapRelations` Sequel plugin.
When this option is provided with a list of index name patterns, any `Sequel::UniqueConstraintViolation` error that occurs during an `add_` operation on an association and matches one of the patterns will be caught.
The operation is wrapped in a transaction with a savepoint, which is rolled back upon catching the specific error, effectively making the addition idempotent. This prevents race conditions where concurrent requests attempt to add the same association.
This issue can be observed when a user makes two POST requests at the same time to create a new resource instance.

This new option is applied to the `staging_spaces relationship in the `SecurityGroup` model to handle potential concurrent updates. Further models will updated in separate commits.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant