This repository has been archived by the owner on Aug 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
feat: Upgrade SQLAlchemy v1.4 for native asyncio support #406
Merged
achimnol
merged 21 commits into
main
from
feature/upgrade-sqlalchemy-with-asyncio-support
Mar 24, 2021
Merged
feat: Upgrade SQLAlchemy v1.4 for native asyncio support #406
achimnol
merged 21 commits into
main
from
feature/upgrade-sqlalchemy-with-asyncio-support
Mar 24, 2021
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* It is now reproducible reliably with the new SQLAlchemy + asyncpg combination! * Also fixed a hidden type conversion bug in AgentRegistry.set_kernel_status() due to a comma typo....
Codecov Report
@@ Coverage Diff @@
## main #406 +/- ##
==========================================
+ Coverage 46.70% 48.66% +1.96%
==========================================
Files 51 52 +1
Lines 8250 8267 +17
==========================================
+ Hits 3853 4023 +170
+ Misses 4397 4244 -153
Continue to review full report at Codecov.
|
* Eliminate manual primary key checks for duplicate entries by utilizing PostgreSQL's "on conflict" (upsert) support. * Fix up using special characters in database passwords by correctly escaping them using `urllib.parse.quote_plus()`.
* rowcount in SQLAlchemy does NOT represent the number of fetched rows for SELECT queries, in contrast to the Python's standard DB API.
…ries * refs MagicStack/asyncpg#530: apply "jit: off" option to DB connections - It is specified in `ai.backend.manager.models.base.pgsql_connect_opts` * Reuse the same single connection for all GraphQL resolvers and mutation methods
achimnol
added a commit
that referenced
this pull request
Mar 24, 2021
* fix: a long-standing transaction error - It is now reproducible reliably with the new SQLAlchemy + asyncpg combination! - Also fixed a hidden type conversion bug in AgentRegistry.set_kernel_status() due to a comma typo.... * fix/test: Update codes for population of DB fixtures - Eliminate manual primary key checks for duplicate entries by utilizing PostgreSQL's "on conflict" (upsert) support. - Fix up using special characters in database passwords by correctly escaping them using `urllib.parse.quote_plus()`. * fix: Do not rely on `rowcount` for SELECT queries - rowcount in SQLAlchemy does NOT represent the number of fetched rows for SELECT queries, in contrast to the Python's standard DB API. * fix: excessive DB connection establishment delay and optimize GQL queries - refs MagicStack/asyncpg#530: apply "jit: off" option to DB connections - It is specified in `ai.backend.manager.models.base.pgsql_connect_opts` - Reuse the same single connection for all GraphQL resolvers and mutation methods * fix: consistently use urlquote for db passwords * fix: all DB connections are now transactions * refactor: Finally, rename "dbpool" to "db" Backported-From: main Backported-To: 20.09
achimnol
added a commit
that referenced
this pull request
Mar 25, 2021
* Follow-up fixes for #406 - fix: sqlalchemy's Row Proxy's get() method seems to be deprecated - fix: typo in referencing unmanaged_path Co-authored-by: Jonghyun Park <adrysn@gmail.com>
achimnol
added a commit
that referenced
this pull request
Mar 25, 2021
* Follow-up fixes for #406 - fix: sqlalchemy's Row Proxy's get() method seems to be deprecated - fix: typo in referencing unmanaged_path Co-authored-by: Jonghyun Park <adrysn@gmail.com> Backported-From: main Backported-To: 20.09
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Internal ticket: OP#1161
Major changes:
SAConnection
,SAEngine
(previouslySAPool
)RowProxy
is deprecated and replaced withsa.engine.row.Row
Row
still supports__getitem__()
interface but we need to useRow._mapping
if we need other dict-like interfaces such as.get(key, default)
.async with dbpool.acquire() as conn:
-->async with dbpool.connect() as conn:
await result.{fetchall,scalar,first}()
-->result.{fetchall,scalar,first}()
because the result is already buffered byawait conn.execute()
await conn.stream(query)
instead ofawait conn.execute(query)
.as_scalar()
and use.scalar_subquery()
for scalar-valued subqueriesasync with conn.begin():
) since now the default reset-on-return behavior is "rollback"dbpool
todb