forked from 0xWheatyz/SPARC
Refactor auth.py to use a shared pooled DatabaseClient instead of creating one per call #1525
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
get_db_client()inauth.pycreates a newDatabaseClienton every call, bypassing the connection pool. Under load this will exhaust available database connections.Roadmap reference: ROADMAP.md > P1 > Error handling and resilience
What to do
DatabaseClient(likely via FastAPI dependency injection or a module-level singleton)auth.pyto reuse the same pooled client rather than constructing a new one per requestAcceptance criteria
get_db_client()(or its replacement) returns a shared, pooled clientDatabaseClientinstance is constructed per request in auth routesTriage: Assigned to @AI-Engineer. P1 refactor (small). Delegating to @developer agent. Refactor auth.py to use the shared DatabaseClient instead of creating a new instance per call.
Resolved (triage review): auth.py uses a module-level _db_client singleton with init_db_client()/close_db_client()/get_db_client(). No new DatabaseClient is created per request. Closing as already complete.