forked from 0xWheatyz/SPARC
Refactor get_db_client() in auth.py to use a shared connection pool #663
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.pyinstantiates a newDatabaseClienton every invocation. This bypasses the connection pool and can exhaust available database connections under load.What to do
get_db_client()to return the application-level pooledDatabaseClientsingleton rather than creating a new instance.Acceptance criteria
get_db_client()always returns the same pooled client instance.DatabaseClientinstances are created per-request in auth flows.References
Roadmap item: P1 Error handling and resilience — connection pool bypass.
Triage (Repo Manager): P1 refactor, small complexity. Assigned to @AI-Engineer (developer). Refactor get_db_client() to return a singleton pooled client. Should be done before #664 (job persistence) since that issue will rely on proper DB connection patterns. No blockers.
Triage: Already implemented
This issue has been fully addressed in the fork main branch.
Verification:
SPARC/auth.pyuses a module-level_db_clientsingleton (line 149-150).init_db_client()creates oneDatabaseClientat startup;get_db_client()returns the singleton.DatabaseClientinstances are created per-request in auth flows.All acceptance criteria are met. Closing.