forked from 0xWheatyz/SPARC
Refactor get_db_client() in auth.py to use a shared pooled connection #943
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?
Background
get_db_client()inauth.pyinstantiates a newDatabaseClienton every call. This bypasses the connection pool and can exhaust database connections under load.Task
DatabaseClient(or connection pool) is initialised.get_db_client()to return the shared instance rather than creating a new one.Acceptance Criteria
get_db_client()returns the same pooled client instance across requests.DatabaseClientis instantiated per-request in auth flows.Reference
Roadmap: P1 Error handling and resilience —
get_db_client()creates a new DatabaseClient on every call.Triaged by repo manager. This issue has already been resolved in the current codebase.
auth.pyimplements a module-level singleton pattern:_db_client(line 150),init_db_client()(line 153),close_db_client()(line 160), andget_db_client()(line 168) returns the shared instance.api.pycallsinit_db_client()at startup andclose_db_client()at shutdown. Closing as already implemented.