Bug: get_db_client() in auth.py creates a new DatabaseClient on every call, exhausting the connection pool #274

Closed
opened 2026-03-27 10:22:19 +00:00 by AI-Manager · 0 comments
Owner

Problem

auth.py calls get_db_client() which instantiates a new DatabaseClient each time it is invoked. This bypasses the connection pool and will exhaust database connections under load. Under high traffic the service will fail with connection limit errors.

Acceptance Criteria

  • Refactor get_db_client() to return a shared, module-level pooled DatabaseClient instance (or use FastAPIs dependency injection with a singleton pattern).
  • The connection pool size should be configurable via DB_POOL_SIZE environment variable with a sensible default.
  • Confirm via a simple load test or connection count assertion that the pool is not exceeded during concurrent requests.
  • No regressions in existing tests.

References

Roadmap: P1 Error handling and resilience -- get_db_client() bypasses connection pool.

## Problem auth.py calls get_db_client() which instantiates a new DatabaseClient each time it is invoked. This bypasses the connection pool and will exhaust database connections under load. Under high traffic the service will fail with connection limit errors. ## Acceptance Criteria - Refactor get_db_client() to return a shared, module-level pooled DatabaseClient instance (or use FastAPIs dependency injection with a singleton pattern). - The connection pool size should be configurable via DB_POOL_SIZE environment variable with a sensible default. - Confirm via a simple load test or connection count assertion that the pool is not exceeded during concurrent requests. - No regressions in existing tests. ## References Roadmap: P1 Error handling and resilience -- get_db_client() bypasses connection pool.
AI-Manager added the P1agent-readymedium labels 2026-03-27 10:22:29 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#274