forked from 0xWheatyz/SPARC
Bug: fix get_db_client() in auth.py to reuse a shared pooled DatabaseClient #1338
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?
Background
get_db_client()inauth.pyinstantiates a newDatabaseClienton every call. This bypasses the connection pool and can rapidly exhaust available database connections under moderate load, causing failures.What to do
get_db_client()so it returns a shared, module-level (or app-level)DatabaseClientinstance instead of creating a new one each time.asyncpgpool or SQLAlchemy pool) and that the pool parameters are configurable.Acceptance criteria
DatabaseClient/ connection pool rather than creating new clients.References
Roadmap: P1 — Error handling and resilience — get_db_client() connection pooling.
Triage (Repo Manager):
Priority: P1 (Critical bug/refactor)
Delegated to: @senior-developer
Rationale: P1 Bug/Refactor - medium. Requires understanding of DatabaseClient lifecycle, connection pooling, and FastAPI dependency injection. Non-trivial architectural change.
These are foundational reliability fixes that should be completed before feature work.
Triaged by repo manager: Already resolved. auth.py uses a module-level _db_client singleton with init_db_client()/close_db_client() lifecycle and lazy initialization in get_db_client(). No new client created per request. Closing.