forked from 0xWheatyz/SPARC
Refactor get_db_client() in auth.py to use a shared connection pool #1548
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 call. This bypasses any connection pooling logic and can exhaust available database connections under concurrent load.Roadmap reference: ROADMAP.md > P1 > Error handling and resilience > get_db_client() creates a new DatabaseClient on every call
What to do
database.pyor the FastAPI lifespan context).get_db_client()(or replace it with a FastAPI dependency) to yield the shared pooled client instead of creating a new one.DatabaseClientinstances are created per-request.Acceptance criteria
DatabaseClient(or pool) is created at application startup.This issue has been resolved. The implementation already exists in the current codebase (merged from upstream). Verified by repo manager during triage on 2026-04-19.