forked from 0xWheatyz/SPARC
Refactor get_db_client() in auth.py to use a shared pooled connection #1572
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.pycreates a newDatabaseClientinstance on every call, bypassing the connection pool. Under load this can exhaust available database connections.What to do
auth.pyto share a singleDatabaseClientinstance (or dependency-inject the existing pooled client used elsewhere in the app)Depends) to pass the shared DB client into auth endpointsAcceptance criteria
get_db_client()no longer instantiates a new client on every callRef: ROADMAP.md P1 - Error handling and resilience
[Manager Triage] Assigned to @AI-Engineer. Priority: P2 (code quality/refactoring). Developer-level change.
Triage: Already Resolved
The
get_db_client()function inSPARC/auth.py(line 168) returns a module-level singletonDatabaseClientthat usesThreadedConnectionPoolfrom psycopg2 (defined inSPARC/database.py). No per-request connection creation.Closing as resolved.