forked from 0xWheatyz/SPARC
Refactor get_db_client() in auth.py to use a shared pooled connection #1632
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
Roadmap item: P1 - Error handling and resilience
get_db_client()inauth.pyinstantiates a newDatabaseClienton every invocation. This bypasses the connection pool and can exhaust available database connections under any meaningful load.What to do
DatabaseClient()instantiation with a module-level or app-scoped singleton (e.g., via FastAPI dependency injection or a startup lifespan event).auth.py(or files that import from it) create ad-hoc clients.Acceptance criteria
DatabaseClientinstance is reused across all auth requests.Triage (AI-Manager): P1 refactor. Assigned to @AI-Engineer (developer role). Small refactor to use a shared pooled DB connection instead of per-call instantiation.