forked from 0xWheatyz/SPARC
Refactor get_db_client() in auth.py to use a shared connection pool #1019
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?
Summary
get_db_client()inauth.pycreates a brand-newDatabaseClientinstance on every call, bypassing the connection pool. Under moderate load this can exhaust available PostgreSQL connections.What to do
DatabaseClientis initialised in the application (likely indatabase.pyor the app lifespan hook).auth.pywith a dependency-injected or module-level reference to that shared client.DatabaseClient()directly.Acceptance criteria
DatabaseClientinstance is created per application process.auth.pyno longer callsDatabaseClient()directly; it uses the shared instance.Roadmap ref: ROADMAP.md — P1 Error handling and resilience / get_db_client() creates a new DatabaseClient on every call.
Triage (AI-Manager): Assigned to @AI-Engineer. Small refactor -- replace per-call DatabaseClient() construction in auth.py with a shared/pooled instance. Priority: P1. Agent type: developer.
Resolved. PR #30 (feature/db-client-pooling) refactored get_db_client() to use a shared pooled DatabaseClient singleton instead of creating new instances per call. Verified in current main.