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

Bug/deleting docker image result in an integrity error for variant #1853

Conversation

aybruhm
Copy link
Member

@aybruhm aybruhm commented Jul 7, 2024

Description

When reserving an app from the CLI, we delete the Docker image associated with the LLM app container to rebuild and assign a new Docker image. During the deletion of the Docker image (app_manager.py line 157 -> update_variant_image function), PostgreSQL raises an IntegrityError exception:

raise translated_error from error
sqlalchemy.exc.IntegrityError: (sqlalchemy.dialects.postgresql.asyncpg.IntegrityError) <class 'asyncpg.exceptions.ForeignKeyViolationError'>: update or delete on table "docker_images" violates foreign key constraint "app_variants_image_id_fkey" on table "app_variants"
DETAIL:  Key (id)=(01908b54-98c0-7528-8604-3653162c7e74) is still referenced from table "app_variants".
[SQL: DELETE FROM docker_images WHERE docker_images.id = $1::UUID]
[parameters: (UUID('01908b54-98c0-7528-8604-3653162c7e74'),)]
(Background on this error at: https://sqlalche.me/e/20/gkpj)

This PR addresses the issue by ensuring the image_id column in the app_variants table allows NULL values. Although we had previously defined an ondelete behaviour, the missing nullable setting caused PostgreSQL to raise the mentioned error above.

Copy link

vercel bot commented Jul 7, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
agenta ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 7, 2024 4:32am

@dosubot dosubot bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Jul 7, 2024
@aybruhm aybruhm requested a review from aakrem July 7, 2024 04:33
@dosubot dosubot bot added Backend bug Something isn't working labels Jul 7, 2024
Copy link
Collaborator

@aakrem aakrem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @aybruhm

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jul 7, 2024
@aakrem aakrem merged commit 5efcb37 into postgres Jul 7, 2024
6 checks passed
@aakrem aakrem deleted the bug/deleting-docker-image-result-in-an-integrity-error-for-variant branch July 7, 2024 08:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backend bug Something isn't working lgtm This PR has been approved by a maintainer size:XS This PR changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants