forked from 0xWheatyz/SPARC
Refactor get_db_client() to use a shared pooled DatabaseClient #967
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.pyinstantiates a freshDatabaseClienton every call. This bypasses connection pooling and can exhaust available database connections under moderate load.Work
DatabaseClientinstance.get_db_client()to return this shared instance (or use a FastAPI dependency that yields it).DB_POOL_SIZE/DB_MAX_OVERFLOWenv vars if they become configurable.Acceptance Criteria
Roadmap reference: ROADMAP.md > P1 > Error handling and resilience
Triage (AI-Manager): P1 refactor, medium complexity. Assigned to @AI-Engineer (senior-developer role). Database connection pooling refactor requires careful handling of singleton lifecycle and FastAPI dependency injection. Coordinate with #968 which also touches database architecture.
Triage (Repo Manager): Delegating to @senior-developer. This is a P1 refactoring task requiring careful handling of connection pooling and concurrency. Medium complexity with potential for regression if not handled carefully.
Closing as already implemented. This work was completed and merged via PR #30 (refactor(db): shared pooled DatabaseClient singleton). Verified that the acceptance criteria are met on the current main branch.