Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Django ORM leaves DB connections open #575

Closed
ciur opened this issue Jan 7, 2024 · 2 comments
Closed

Django ORM leaves DB connections open #575

ciur opened this issue Jan 7, 2024 · 2 comments
Assignees
Labels
blocker bug Something isn't working critical

Comments

@ciur
Copy link
Owner

ciur commented Jan 7, 2024

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
@ciur ciur added the bug Something isn't working label Jan 7, 2024
@ciur ciur self-assigned this Jan 7, 2024
@ciur ciur changed the title Django ORM leaves open connections on IDLE Django ORM leaves open connections in IDLE state Jan 7, 2024
@ciur ciur changed the title Django ORM leaves open connections in IDLE state Django ORM leaves DB connections open Jan 7, 2024
@ciur
Copy link
Owner Author

ciur commented Jan 9, 2024

First PR which fixes couple of critical endpoints: papermerge/papermerge-core#292

@ciur
Copy link
Owner Author

ciur commented Jan 10, 2024

PR 2: papermerge/papermerge-core#294
PR 3: papermerge/papermerge-core#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.

@ciur ciur closed this as completed Jan 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocker bug Something isn't working critical
Projects
None yet
Development

No branches or pull requests

1 participant