Remove db.close() from handle_db_errors error handler #38

Open
opened 2026-02-20 06:51:18 +00:00 by cal · 1 comment
Owner

app/dependencies.py:774-778 — The error handler explicitly closes a pooled database connection after rollback. Combined with manual db.close() calls in route handlers, connections may be returned to the pool twice, causing pool state corruption. Connection management should be centralized.

Priority: medium | Labels: bug, tech-debt

`app/dependencies.py:774-778` — The error handler explicitly closes a pooled database connection after rollback. Combined with manual `db.close()` calls in route handlers, connections may be returned to the pool twice, causing pool state corruption. Connection management should be centralized. **Priority**: medium | **Labels**: bug, tech-debt
cal added the
ai-working
label 2026-03-05 16:01:26 +00:00
Author
Owner

Fixed in PR #42: #42

Removed the finally block from handle_db_errors that called db.close() after rollback. With PostgreSQL connection pooling, route handlers already manage db.close() themselves — closing again in the error handler risked returning connections to the pool twice, corrupting pool state.

Fixed in PR #42: https://git.manticorum.com/cal/major-domo-database/pulls/42 Removed the `finally` block from `handle_db_errors` that called `db.close()` after rollback. With PostgreSQL connection pooling, route handlers already manage `db.close()` themselves — closing again in the error handler risked returning connections to the pool twice, corrupting pool state.
cal added
ai-pr-opened
and removed
ai-working
labels 2026-03-05 16:03:11 +00:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: cal/major-domo-database#38
No description provided.