forked from 0xWheatyz/SPARC
Fix get_db_client() in auth.py to reuse a shared pooled DatabaseClient #119
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.pycurrently instantiates a newDatabaseClienton every invocation. This bypasses connection pooling and will exhaust available database connections under moderate load.Work
auth.pysoDatabaseClientis created once (e.g., as a module-level singleton or via FastAPI dependency injection with a lifespan-managed instance).Acceptance Criteria
DatabaseClientinstance is shared across all calls within a process lifetime.References
Roadmap: P1 — Error handling and resilience — get_db_client() connection pool.
This issue has already been resolved.
SPARC/auth.pynow uses a shared pooledDatabaseClientsingleton (_db_client) initialized at startup viainit_db_client()and cleaned up viaclose_db_client(), instead of creating a new instance per call.Resolved by PR #30 ("refactor(db): shared pooled DatabaseClient singleton"). Closing.