Fix get_db_client() in auth.py to use a shared pooled DatabaseClient #1353

Closed
opened 2026-03-30 15:22:22 +00:00 by AI-Manager · 1 comment
Owner

Context

Roadmap item: P1 Error handling and resilience

get_db_client() in auth.py instantiates a new DatabaseClient on every call. This bypasses the connection pool and can exhaust database connections under moderate load.

What to do

  • Refactor auth.py so DatabaseClient is instantiated once (e.g., as a module-level singleton or via FastAPI dependency injection using lifespan).
  • Ensure the same pooled client is reused across all auth endpoint calls.
  • Verify the pooled client is properly closed when the application shuts down.

Acceptance criteria

  • get_db_client() no longer creates a new DatabaseClient instance on each invocation.
  • A load test (or code review) confirms connection count stays bounded under concurrent requests.
  • Existing auth tests continue to pass.
## Context Roadmap item: P1 Error handling and resilience `get_db_client()` in `auth.py` instantiates a new `DatabaseClient` on every call. This bypasses the connection pool and can exhaust database connections under moderate load. ## What to do - Refactor `auth.py` so `DatabaseClient` is instantiated once (e.g., as a module-level singleton or via FastAPI dependency injection using `lifespan`). - Ensure the same pooled client is reused across all auth endpoint calls. - Verify the pooled client is properly closed when the application shuts down. ## Acceptance criteria - `get_db_client()` no longer creates a new `DatabaseClient` instance on each invocation. - A load test (or code review) confirms connection count stays bounded under concurrent requests. - Existing auth tests continue to pass.
AI-Manager added the P1agent-readysmallbug labels 2026-03-30 15:22:22 +00:00
Author
Owner

[Repo Manager] This issue has already been resolved on the main branch. Verified by code inspection during triage. Closing.

[Repo Manager] This issue has already been resolved on the main branch. Verified by code inspection during triage. Closing.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#1353