[DB] Make skypilot config db use alembic again #7705
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Normally, we store the sky config yaml on disk, in
~/.sky/config.yaml. But when using Postgres, we store the sky config yaml in the DB (config_yamltable) instead.When profiling, I noticed that we are wasting 1 RTT to the DB to try creating the
skypilot_configtable on the DB. We do this for every request, as this is done inreload_config().Instead, we should just be making sure that all the tables are up to date once when the server starts. As part of this, we should bring back alembic for sky config, as it makes things easier to manage too. We had tried moving skypilot config table to use alembic, but reverted it (#6320) as we encountered some race conditions.
This PR brings back alembic for skypilot config. There shouldn't be any race conditions this time, as we are only initializing the db once, at module import (and thus at server startup too) time, not lazily inside another function.
Benchmarked with
multitime -n 50 sky status:Before:
After:
TODO: try to make a smoke test with postgres + some config editing (?)
Tested (run the relevant ones):
bash format.sh/smoke-test(CI) orpytest tests/test_smoke.py(local)/smoke-test -k test_name(CI) orpytest tests/test_smoke.py::test_name(local)/quicktest-core(CI) orpytest tests/smoke_tests/test_backward_compat.py(local)