-
Notifications
You must be signed in to change notification settings - Fork 864
[DB] use queue pool for async db engine #8005
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
Conversation
|
/quicktest-core |
|
/smoke-test -k test_managed_jobs_basic |
|
/smoke-test --postgres -k test_managed_jobs_logs_gc |
|
/smoke-test --postgres -k test_nonexistent_bucket |
|
/smoke-test -k test_managed_jobs_basic |
|
Can we also mention what is the major benefits we are getting from this? |
|
/smoke-test --postgres -k test_managed_jobs_logs_gc |
1 similar comment
|
/smoke-test --postgres -k test_managed_jobs_logs_gc |
aa1d855 to
4859e35
Compare
Updated the PR description |
SeungjinYang
left a comment
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.
Thanks @rohansonecha! Couple of minor comments, but this should be a meaningful improvement to DB efficiency
| conn_string, poolclass=sqlalchemy.pool.NullPool)) | ||
| kw_args = {'poolclass': sqlalchemy.NullPool} | ||
| if async_engine: | ||
| _postgres_engine_cache[conn_string] = ( |
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.
I do understand you don't need a separate engine cache for async and sync engines because their conn str would be different, but I actually suggest separating them out on a readability argument (so there's no second guessing involved at all)
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.
Eh, I thought this would be easy enough because I thought all cases where code gets / sets from cache is if / elsed on sync / async anyway, but that's not the case. I'm fine with you adding a comment somewhere in code on why it's safe to use the same cache across sync and async engines.
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.
Discussed offline, but I think adding a separate engine cache would clutter the logic in this code block. I added a comment to improve the clarity and future maintainability of this code path.
Co-authored-by: Seung Jin <[email protected]>
|
/quicktest-core |
Addresses #7829 (review). The main benefit for using
QueuePoolsas compared toNullPoolsis that connection pooling allows maintaining long running connections in memory for efficient re-use (ref).Tested with local postgres (
NullPools), initialized the sync engine as well as the async engine. Sync engine is initialized by most normal operations likesky launch,sky status, etc. Async engine is used by provision logs for checking the cluster status, so I ran provision logs during cluster launch to verify proper async engine initialization.I ran the same tests described above with a remote api server and a beefy cloud sql instance to force using
QueuePoolsand veriifed that both sync and async engine initialization works as expected.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)