-
Notifications
You must be signed in to change notification settings - Fork 40
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 unique constraints for images #3254
Conversation
Great news if that's all it takes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great assuming you confirmed the test fails without the index change.
Co-authored-by: David Crespo <[email protected]>
Yeah, the only issue is that when the constraint check fails it's a 500 which is not what we want. Need to add some logic around catching that. |
That's usually a case where something wants to be using |
Yeah, that was my conclusion. Unfortunately there's a slight hiccup in that |
As an update on this I paid with @davepacheco and he helped me with some query execution analysis. The query to list a project's images combined with silo images (which is used for situations like instance create) ends up doing a full table scan. We were able to avoid the full table scan by breaking it down into two select queries with a UNION clause combining the results. Diesel exposes capacities for performing a union but I've been struggling to figure out how to slot that in with our current paginated approach. |
I've decided to sidestep the whole issue with the query and just remove the |
So how do you get a list of silo images? |
The images list endpoint already had to modes. |
Oh right. I forgot about selecting with no param. So the console will just make two requests. No problem. |
Fixes #2895
As @davepacheco pointed out in #2895, CRDB doesn't treat
null
as unique which ultimately means duplicate entries can be present. To prevent that I've broken down the constraint down into two indices to ensure the unique constraint is enforced.