Skip to content
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

fix(org): Address bug that prevented deleting an org #2465

Merged
merged 1 commit into from
Sep 19, 2022
Merged

Conversation

tmessi
Copy link
Member

@tmessi tmessi commented Sep 16, 2022

The schema changes introduced in 0.10.2 introduced a bug where an org
could not be deleted if there was a session for an org scoped user. It
would result in an error like:

scope.(Service).deleteFromRepo: unable to delete scope: \
    iam.(Repository).DeleteScope: failed for o_VkNy46KwfS: \
    iam.(Repository).delete: db.DoTx: iam.(Repository).delete: \
    db.Delete: insert or update on table "session" violates foreign key constraint "target_fkey": integrity violation: error #1003

A worker around would be to first delete all projects in the org, then
finally delete the org.

This fix adds a regression test to the sqltests and updates several
constraints on the session table to be deferrable. Since the org delete
is a single transaction, this allows all of the necessary resources to
be deleted before attempting to enforce these constrains.

See: https://www.postgresql.org/docs/current/sql-set-constraints.html
Blame: 3a28ab6

@tmessi tmessi force-pushed the tmessi-fix-org-del branch 2 times, most recently from 72dd09d to fd37472 Compare September 19, 2022 13:28
The schema changes introduced in 0.10.2 introduced a bug where an org
could not be deleted if there was a session for an org scoped user. It
would result in an error like:

    scope.(Service).deleteFromRepo: unable to delete scope: \
        iam.(Repository).DeleteScope: failed for o_VkNy46KwfS: \
        iam.(Repository).delete: db.DoTx: iam.(Repository).delete: \
        db.Delete: insert or update on table "session" violates foreign key constraint "target_fkey": integrity violation: error #1003

A worker around would be to first delete all projects in the org, then
finally delete the org.

This fix adds a regression test to the sqltests and updates several
constraints on the session table to be deferrable. Since the org delete
is a single transaction, this allows all of the necessary resources to
be deleted before attempting to enforce these constrains.

See: https://www.postgresql.org/docs/current/sql-set-constraints.html
Blame: 3a28ab6
@tmessi tmessi merged commit a2ef142 into main Sep 19, 2022
@tmessi tmessi deleted the tmessi-fix-org-del branch September 19, 2022 13:47
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.

2 participants