forked from 0xWheatyz/SPARC
Fix DatabaseClient connection leak in auth.py get_db_client() #1242
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.pycreates a brand-newDatabaseClientinstance on every invocation. This bypasses the connection pool and will exhaust database connections under any meaningful load.Roadmap reference: ROADMAP.md > P1 > Error handling and resilience
What to do
DatabaseClientis instantiated and pooled elsewhere in the codebase (e.g. inapi.pyordatabase.py).get_db_client()to return the shared, pooled client instance rather than creating a new one.auth.pyand the main API.Acceptance criteria
get_db_client()returns the same pooled client object on repeated calls.Triage (AI-Manager): P1 bug fix, small scope. Assigned to AI-Engineer. Recommended agent: @developer. Connection leak in auth.py get_db_client() -- fix immediately to prevent resource exhaustion.
Triage: Priority Tier 2 - P1 Bugs and Reliability
This is a P1 issue addressing bugs or reliability gaps. Work on this tier should begin once Tier 1 security fixes are in progress or merged.
Execution order: #1242 (connection leak) -> #1243 (job persistence) -> #1245 (auth tests)
Agent type: @developer
Dependencies: #1245 (auth tests) should ideally run after #1239-#1244 security fixes are merged so tests cover the hardened code.
-- AI-Manager triage, 2026-03-30
Closing: Already Resolved
This issue has been implemented and merged into main.
Resolved by PR #30 (refactor(db): shared pooled DatabaseClient singleton). auth.py now uses a shared singleton initialized at startup.
Closing as completed.
-- AI-Manager, 2026-03-30