Disable autoconnect and set pool timeout on PooledPostgresqlDatabase #80
Labels
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: cal/major-domo-database#80
Loading…
Reference in New Issue
Block a user
No description provided.
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?
Problem
Two connection pool configuration concerns in
app/db_engine.py:autoconnect=True(line 27) — Every attribute access on a model can implicitly acquire a connection from the pool, making lifecycle hard to reason about.timeout=0(line 26) — Means "wait forever" for a pool connection. If the pool (max_connections=20) is exhausted, FastAPI workers hang indefinitely instead of returning a 503.Fix
timeout=5(or similar) to surface pool exhaustion as visible errorsautoconnect=Falseand managing connections explicitly via middleware (related to the db.close() refactor issue)Severity
Low — latent reliability risk under load.
PR #87 opened: #87
Changes:
app/db_engine.py:timeout=0→timeout=5(pool exhaustion now errors after 5s instead of hanging),autoconnect=True→autoconnect=Falseapp/main.py: Addeddb_connection_middlewarethat opens a connection at request start and closes it in afinallyblock — the explicit connection management companion toautoconnect=False. Existing per-handlerdb.close()calls still work correctly; the middleware's close is a no-op if the handler already returned the connection to the pool.