[Django] #32305: Add an option to limit the number of connections to a database

12 views
Skip to first unread message

Django

unread,
Dec 29, 2020, 10:51:18 PM12/29/20
to django-...@googlegroups.com
#32305: Add an option to limit the number of connections to a database
-------------------------------------+-------------------------------------
Reporter: Barney | Owner: nobody
Szabolcs |
Type: | Status: new
Cleanup/optimization |
Component: Core | Version: 3.0
(Other) |
Severity: Normal | Keywords: db connection leak
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
With the introduction of threads in Django 3.0, somehow only changing from
Django 2.2.x to Django 3.0 causes the number of connections to build up
with each request a new connection being added.
Probably this pile-up is because a bug in one of the django packages.
However, it would be nice to have a safety feature in Django not to exceed
a limit of database connections. It would make the whole system a lot more
robust.
(At the moment it is not even worth to switch for some long term users who
use a long list of packages along with Django because the db connection
buildup has no straightforward solution, yet.)

--
Ticket URL: <https://code.djangoproject.com/ticket/32305>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Dec 29, 2020, 10:52:31 PM12/29/20
to django-...@googlegroups.com
#32305: Add an option to limit the number of connections to a database
-------------------------------------+-------------------------------------
Reporter: Barney Szabolcs | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Core (Other) | Version: 3.0
Severity: Normal | Resolution:

Keywords: db connection leak | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Barney Szabolcs:

Old description:

> With the introduction of threads in Django 3.0, somehow only changing
> from Django 2.2.x to Django 3.0 causes the number of connections to build
> up with each request a new connection being added.
> Probably this pile-up is because a bug in one of the django packages.
> However, it would be nice to have a safety feature in Django not to
> exceed a limit of database connections. It would make the whole system a
> lot more robust.
> (At the moment it is not even worth to switch for some long term users
> who use a long list of packages along with Django because the db
> connection buildup has no straightforward solution, yet.)

New description:

With the introduction of threads in Django 3.0, somehow only changing from

Django 2.2.x to Django 3.0 causes the number of connections to build up,


with each request a new connection being added.

Probably this pile-up is because of some bug in one of the Django-related


packages. However, it would be nice to have a safety feature in Django not
to exceed a limit of database connections. It would make the whole system
a lot more robust.
(At the moment it is not even worth to switch for some long term users who
use a long list of packages along with Django because the db connection
buildup has no straightforward solution, yet.)

--

--
Ticket URL: <https://code.djangoproject.com/ticket/32305#comment:1>

Django

unread,
Dec 30, 2020, 6:17:47 AM12/30/20
to django-...@googlegroups.com
#32305: Add an option to limit the number of connections to a database
-------------------------------------+-------------------------------------
Reporter: Barney Szabolcs | Owner: nobody
Type: New feature | Status: closed
Component: Database layer | Version: 3.0
(models, ORM) |
Severity: Normal | Resolution: needsinfo

Keywords: db connection leak | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* status: new => closed
* resolution: => needsinfo
* component: Core (Other) => Database layer (models, ORM)
* type: Cleanup/optimization => New feature


Comment:

Hi Barney.

> With the introduction of threads in Django 3.0, somehow only changing
from Django 2.2.x to Django 3.0 causes the number of connections to build

up, with each request a new connection being added.

This is something worth looking at if you can demonstrate it with a
minimal project. There really shouldn't be a regression here.

In general I think tracking connections isn't in scope for Django itself.
We'd suggest using a connection pool (e.g. PgBouncer) for your database,
or similar approaches.

--
Ticket URL: <https://code.djangoproject.com/ticket/32305#comment:2>

Django

unread,
Dec 30, 2020, 6:19:21 AM12/30/20
to django-...@googlegroups.com
#32305: Add an option to limit the number of connections to a database
-------------------------------------+-------------------------------------
Reporter: Barney Szabolcs | Owner: nobody
Type: New feature | Status: closed
Component: Database layer | Version: 3.0
(models, ORM) |
Severity: Normal | Resolution: wontfix

Keywords: db connection leak | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* resolution: needsinfo => wontfix


Comment:

I'll mark this wontfix on the new feature, but happy to review an example
showing the issue (hence the initial needsinfo) – hope that makes sense.

--
Ticket URL: <https://code.djangoproject.com/ticket/32305#comment:3>

Reply all
Reply to author
Forward
0 new messages