[GH-ISSUE #575] Django ORM leaves DB connections open #449

Closed
opened 2026-02-25 21:31:57 +03:00 by kerem · 2 comments
Owner

Originally created by @ciur on GitHub (Jan 7, 2024).
Original GitHub issue: https://github.com/ciur/papermerge/issues/575

Originally assigned to: @ciur on GitHub.

Django ORM leaves open database connections in IDLE state for following REST API endpoints:

- GET /api/users/me
- GET /api/nodes/<id>
- GET /api/thumbnails/<id>
- GET /api/documents/<id>
- GET /api/pages/<id>/jpg
- GET /api/pages/<id>/svg

As result connections pile-up and when reaching specific limit, e.g. 100, 50, 25, depending on DB config, the app stops working as DB refuses all further connections. Same behavior was observed for PostgreSQL 16.1 and MariaDB 11.2.

Expected behavior: DB connections should be released when not used; or number of DB connections should remain stable when connection pooling is employed.

Info:

  • Browser: any
  • PostgreSQL 16.1
  • Papermerge 3.0
Originally created by @ciur on GitHub (Jan 7, 2024). Original GitHub issue: https://github.com/ciur/papermerge/issues/575 Originally assigned to: @ciur on GitHub. Django ORM leaves open database connections in IDLE state for following REST API endpoints: ``` - GET /api/users/me - GET /api/nodes/<id> - GET /api/thumbnails/<id> - GET /api/documents/<id> - GET /api/pages/<id>/jpg - GET /api/pages/<id>/svg ``` As result connections pile-up and when reaching specific limit, e.g. 100, 50, 25, depending on DB config, the app stops working as DB refuses all further connections. Same behavior was observed for PostgreSQL 16.1 and MariaDB 11.2. Expected behavior: DB connections should be released when not used; or number of DB connections should remain stable when connection pooling is employed. **Info:** - Browser: any - PostgreSQL 16.1 - Papermerge 3.0
kerem 2026-02-25 21:31:57 +03:00
Author
Owner

@ciur commented on GitHub (Jan 9, 2024):

First PR which fixes couple of critical endpoints: https://github.com/papermerge/papermerge-core/pull/292

<!-- gh-comment-id:1882445721 --> @ciur commented on GitHub (Jan 9, 2024): First PR which fixes couple of critical endpoints: https://github.com/papermerge/papermerge-core/pull/292
Author
Owner

@ciur commented on GitHub (Jan 10, 2024):

PR 2: https://github.com/papermerge/papermerge-core/pull/294
PR 3: https://github.com/papermerge/papermerge-core/pull/295

The solution is to replace Django ORM with SQLAlchemy. Of course ORM replacement it not matter of couple of weeks.
This ticket is for fixing the most critical parts so that app is usable in production.

This fix will be shipped in 3.0.1 release.

<!-- gh-comment-id:1884318850 --> @ciur commented on GitHub (Jan 10, 2024): PR 2: https://github.com/papermerge/papermerge-core/pull/294 PR 3: https://github.com/papermerge/papermerge-core/pull/295 The solution is to replace Django ORM with SQLAlchemy. Of course ORM replacement it not matter of couple of weeks. This ticket is for fixing the most critical parts so that app is usable in production. This fix will be shipped in 3.0.1 release.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
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
starred/papermerge#449
No description provided.