Database is connected
{{{
DATABASES['default'] = dj_database_url.config(conn_max_age=0)
}}}
Since we deployed to production, we have started to experience a database
connection buildup, quickly using up the whole pool of connection allowed
by Postgres. A few minutes after the deploy we only get exception about no
available connections.
We tried upgrading Django to 4.2b1, and Psycopg 3, but the issue still
persisted. Now we tried downgrading Django to 3.1.8, and the connections
are at their usual level, not being used up at all, with everything else
but Django on a different version. This leads me to believe Django is not
closing connections, but it could be due to an issue with our setup.
I would greatly appreciate any help regarding this issue, as this is a
production blocker for us, at least for 4.1.
--
Ticket URL: <https://code.djangoproject.com/ticket/34389>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => closed
* resolution: => needsinfo
Comment:
Thanks for the report. Django has a
[https://github.com/django/django/blob/b05dfc289429dc4de990617da543af681d6638c7/django/db/__init__.py#L53-L61
routine] to clean up old connections that is tied into the request-
response life-cycle, so idle connections should be closed. However, I
don't think you've explained the issue in enough detail to confirm a bug
in Django. This can be an issue in `psycopg2`, `uvicorn`, or in custom
middlewares (see #31905) it's hard to say without a sample project.
Please reopen the ticket if you can debug your issue and provide details
about why and where Django is at fault, or if you can provide a sample
project with reproducible scenario.
See also #33497 and #31134 for potential duplicates.
--
Ticket URL: <https://code.djangoproject.com/ticket/34389#comment:1>