Skip to content

Add unique constraint for running security groups#4617

Merged
johha merged 1 commit intomainfrom
missing-unqiue-constraint-security-groups
Oct 27, 2025
Merged

Add unique constraint for running security groups#4617
johha merged 1 commit intomainfrom
missing-unqiue-constraint-security-groups

Conversation

@johha
Copy link
Copy Markdown
Contributor

@johha johha commented Oct 23, 2025

Table security_group_spaces does not have a unique constraint which can result in duplicated entries. This change adds a migration to replace the existing index with a unique index. Duplicated entries will be cleaned up during the migration by keeping the oldest combination of security_group_id and space_id (determined by primary key). In addition unique constraint errors will be caught to make parallel inserts idempotent.

This will fix #4602.

  • 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

Table `security_group_spaces` does not have unique constraint which can result in duplicated entries.
This change adds a migration to replace the existing index with a unique index.
Duplicated entries will be cleaned up during the migration by keeping the oldest combination of `security_group_id` and `space_id` (determined by primary key).
In addition unique constraint errors will be caught to make parallel inserts idempotent.
@johha johha marked this pull request as ready for review October 24, 2025 07:07
@johha johha requested a review from a team October 24, 2025 07:07
@kathap
Copy link
Copy Markdown
Contributor

kathap commented Oct 24, 2025

lgtm

@johha johha merged commit d7ae589 into main Oct 27, 2025
21 of 22 checks passed
ari-wg-gitbot added a commit to cloudfoundry/capi-release that referenced this pull request Oct 27, 2025
Changes in cloud_controller_ng:

- Add unique constraint for running security groups
    PR: cloudfoundry/cloud_controller_ng#4617
    Author: Johannes Haass <johannes.haass@sap.com>
@moleske moleske deleted the missing-unqiue-constraint-security-groups branch October 27, 2025 14:55
sethboyles pushed a commit to atanas-attodorov-wq/cloud_controller_ng that referenced this pull request Dec 11, 2025
Table `security_group_spaces` does not have unique constraint which can result in duplicated entries.
This change adds a migration to replace the existing index with a unique index.
Duplicated entries will be cleaned up during the migration by keeping the oldest combination of `security_group_id` and `space_id` (determined by primary key).
In addition unique constraint errors will be caught to make parallel inserts idempotent.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Duplicate entries for security_groups_spaces are possible in CCDB

2 participants