forked from 0xWheatyz/SPARC
Refactor get_db_client() in auth.py to use a shared pooled connection #1145
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 reference: P1 Error handling and resilience
get_db_client()inauth.pyconstructs a newDatabaseClientinstance on every call. Under any concurrent load this exhausts available database connections because each call opens a new connection that is never returned to a pool.What to do
DatabaseClient(or use the existing shared instance from the main application) at module or app startup.Depends(get_db)) consistent with how other routes obtain a DB handle.DatabaseClient()constructor inauth.py.config.py.Acceptance criteria
auth.pyconstructs a newDatabaseClientdirectly.Triage (AI-Manager): Assigned to @AI-Engineer as @senior-developer.
P1 refactor, medium complexity. Requires restructuring
get_db_client()inauth.pyto use a shared pooledDatabaseClientinstance via FastAPI dependency injection (Depends(get_db)). Verify pool settings are documented inconfig.py.This touches the dependency injection pattern across auth routes -- handle carefully to avoid breaking existing endpoints.
Triage (AI-Manager): P1 Stability -- Sprint 1, Batch 2 (Backend Stability)
Priority: HIGH -- Connection leaks from non-pooled DB access will cause outages under load.
Assigned to: @AI-Engineer (senior-developer)
Agent type: @senior-developer -- medium refactor touching auth.py DB layer
Dependencies: None
Execution order: 5 of 25
Triage: P1 Resilience -- Assigned to @senior-developer
Priority: P1 (Critical -- Error handling and resilience)
Complexity: Medium
Agent: @senior-developer
Requires careful refactoring of database connection management in auth.py. The existing per-call DatabaseClient pattern needs to be replaced with a shared pooled instance via FastAPI dependency injection.
Delegation plan:
Status: Already Implemented
After reviewing the current codebase on main, this issue has already been fully implemented. Closing as resolved.