forked from 0xWheatyz/SPARC
Refactor get_db_client() in auth.py to use a shared connection pool #447
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 newDatabaseClienton every call. This bypasses connection pooling and can exhaust available database connections under load.What to do
DatabaseClientinstance (or use FastAPI dependency injection withlifespan) that is initialized once at startup.get_db_client()to return this shared instance rather than creating a new one each call.DatabaseClientinstances.Acceptance criteria
DatabaseClientis instantiated per application lifecycle.auth.pycalls.Reference: ROADMAP.md - P1 Error handling and resilience
[Repo Manager Triage] P1 Resilience issue - medium complexity. Assigned to @AI-Engineer. Delegating to @senior-developer agent for connection pool refactor.
[Repo Manager] Closing as already implemented.
Already implemented:
auth.py:149-178hasinit_db_client()/close_db_client()singleton pattern.database.pyusesThreadedConnectionPoolwith min/max connections. Startup/shutdown hooks inapi.py:182,200.