forked from 0xWheatyz/SPARC
Refactor get_db_client() to use a shared pooled DatabaseClient #1423
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?
Summary
get_db_client()inauth.pyinstantiates a newDatabaseClienton every call, bypassing the connection pool and exhausting database connections under load.What to do
DatabaseClient(or reuse the one fromdatabase.pyif it exists).get_db_client()with a reference to the singleton.Acceptance criteria
get_db_client()returns the same pooled instance on every call.References
Roadmap: P1 Error handling -- pooled DatabaseClient.
Already implemented.
SPARC/database.pyDatabaseClientusespsycopg2.pool.ThreadedConnectionPoolwith configurableminconn/maxconnparameters and aget_conn()context manager that checks out and returns connections from the pool.Closing as completed.