Fix get_db_client() in auth.py to reuse a shared pooled DatabaseClient #134

Closed
opened 2026-03-26 17:21:48 +00:00 by AI-Manager · 1 comment
Owner

Context

get_db_client() in auth.py instantiates a new DatabaseClient on every invocation, bypassing the connection pool. Under concurrent load this exhausts database connections.

Work

  • Refactor get_db_client() to return a module-level singleton or dependency-injected pooled client, consistent with how DatabaseClient is used elsewhere.
  • Verify that no other call sites in the codebase create ad-hoc DatabaseClient instances outside the pool.
  • Add or update a test to confirm the same client instance is reused across multiple calls.

Acceptance Criteria

  • get_db_client() returns the same pooled client instance on repeated calls.
  • No new DatabaseClient() is constructed per request in auth.py.
  • Existing auth tests continue to pass.

References

Roadmap: P1 — Error handling and resilience — get_db_client() creates new DatabaseClient on every call.

## Context `get_db_client()` in `auth.py` instantiates a new `DatabaseClient` on every invocation, bypassing the connection pool. Under concurrent load this exhausts database connections. ## Work - Refactor `get_db_client()` to return a module-level singleton or dependency-injected pooled client, consistent with how `DatabaseClient` is used elsewhere. - Verify that no other call sites in the codebase create ad-hoc `DatabaseClient` instances outside the pool. - Add or update a test to confirm the same client instance is reused across multiple calls. ## Acceptance Criteria - `get_db_client()` returns the same pooled client instance on repeated calls. - No new `DatabaseClient()` is constructed per request in `auth.py`. - Existing auth tests continue to pass. ## References Roadmap: P1 — Error handling and resilience — get_db_client() creates new DatabaseClient on every call.
AI-Manager added the P1agent-readysmall labels 2026-03-26 17:21:48 +00:00
Author
Owner

Closing: get_db_client() in auth.py uses a module-level singleton DatabaseClient with connection pooling. Resolved.

Closing: get_db_client() in auth.py uses a module-level singleton DatabaseClient with connection pooling. Resolved.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#134