Skip to content

The ORM is async end to end - #324

Merged
czpython merged 1 commit into
mainfrom
eng-672-async-orm
Aug 24, 2026
Merged

The ORM is async end to end#324
czpython merged 1 commit into
mainfrom
eng-672-async-orm

Conversation

@czpython

Copy link
Copy Markdown
Owner

Flag-day switch of every ORM session to SQLAlchemy's AsyncSession on the serving loop. The sync pool checkout was the last blocking call left in the process: under load it froze the event loop in pool_timeout slices. Now a checkout wait suspends the task — exhaustion is backpressure, not a freeze.

  • Async engine (create_async_engine, pool 20+30) with the sync engine kept only for one-shot processes: migrations, CLI, doctor's plain checks.
  • db_session is an async_scoped_session keyed by task. Each request binds its own session and commits at the boundary; durable steps keep the one-transaction-per-step shape through step_session.
  • DBOS.launch() runs inside the async lifespan so async steps share the serving loop; schedule reconciliation uses the *_async schedule APIs.
  • Model and read surfaces are async def throughout; lazy relationship reads go through awaitable_attrs where a load is intended, and Workflow.subject resolves as an awaitable.
  • Test harness: per-test async engine + savepoint-joined session, and an ASGI-transport client on the test's own loop.

1329 backend tests green; pyright error count below the main baseline.

ENG-672.

🤖 Generated with Claude Code

Flag-day switch of every session to SQLAlchemy's AsyncSession on the
serving loop: async engine + async_scoped_session task registry, a
request-owned session bound per request and committed at the boundary,
step_session for durable steps, and async model/read surfaces
throughout. Sync engines remain only for one-shot processes (migrate,
CLI, doctor's plain checks). ENG-672.
@czpython
czpython merged commit 37bf540 into main Aug 24, 2026
1 check passed
@czpython
czpython deleted the eng-672-async-orm branch August 24, 2026 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant