-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Add fast path for server internal metadata migrations #3686
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
Add fast path for server internal metadata migrations #3686
Conversation
|
Deploy preview for hasura-docs ready! Built with commit f8264cd |
|
Review app for commit ce6e1bc deployed to Heroku: https://hge-ci-pull-3686.herokuapp.com |
fafde1e to
bc925e2
Compare
bc925e2 to
f8264cd
Compare
|
Review app for commit f8264cd deployed to Heroku: https://hge-ci-pull-3686.herokuapp.com |
|
Currently we have I'm wondering if it makes sense to have a query like (The implementation in this PR looks like an interface to |
I considered this, too, and I think it’s a totally viable alternative. I wasn’t sure whether it was better to split out some Eventually, I decided to just do it in the code because that seemed very easy, and it’s very simple to change later. I figured that what we really want is a more general solution to this that helps CLI migrations, too, and maybe at that point we could go back to sharing the same code path, but I couldn’t figure out exactly what I thought that should look like, so I opted to do the simplest thing that seemed least likely to introduce tech debt. That said, I’m really not attached to this, and in fact I’d actually love for someone else to make this decision for me. 😄 If you think I should tweak this to keep the |
|
By the way, I should add why I didn’t want to implement the We could still have something that works like that internally that we use for this code path but not actually expose it as a valid RQL query, and we could adapt it into a full API at some point in the future. But I don’t think it makes sense to add that API right now without more thought and discussion. |
Yup, this was one of the concerns that I had.
Let's keep this implementation for now, given that it improves the startup time. We should definitely think about the right semantics for an |
|
Review app https://hge-ci-pull-3686.herokuapp.com is deleted |
Description
The way we perform internal metadata migrations within
graphql-enginehas a long and storied history.Originally, we just reused the same infrastructure we use for CLI migrations, but this caused #2826. In #2379, we resolved the issue by dropping and recreating all system-defined metadata whenever we migrated the SQL schema, but that in turn caused #3354. The recent incremental schema cache construction changes in #3394 mostly fixed that problem, but as discovered in #3654, the process can still be very slow on underpowered Postgres instances.
This PR adds a fast path for the internal metadata migrations to improve the performance of internal server migrations. It does not affect the performance of user-defined CLI migrations, so it’s not a comprehensive fix, but it’s much simpler to make our own migrations faster (mostly because we don’t have to worry so much about the interface), so this takes advantage of that low-hanging fruit.
Affected components
Related Issues
#3654
Solution and Design
This PR eliminates the use of the CLI migrations code path for performing internal metadata migrations, instead doing it all directly in code in a single batch of queries against the database. This is a little unsatisfying, since it means our internal migrations are “blessed” compared to user-defined CLI migrations, but it’s so easy to do that I decided to give in and make the change.
Server checklist
Catalog upgrade
Does this PR change Hasura Catalog version?
Metadata
Does this PR add a new Metadata feature?
GraphQL
Breaking changes