Skip to content

django-debug-toolbar is crashing postgresql by not closing connections #1799

Closed
@elapouya

Description

@elapouya

I am using Django 4.2.2, django-debug-toolbar 4.1.0, Python 3.11 and Postgresql 15.2
While developing with DEBUG=True and django-debug-toolbar activated in settings.py, after about 100 pages displayed, Postgresql is crashing with the messages.

FATAL: remaining connection slots are reserved for non-replication superuser connections

My max connexion is set at 100 on my Postgresql server. Nevertheless despite I am alone to request pages to Django runserver (there is no concurrency), the opened postgresql connections count is always rising up to the max, then the above message appears.

To check open connections I do :

SELECT count(*) AS total_connections FROM pg_stat_activity;

If I use chrome to consult pages slowly or just a bench with ab -n 200 : I have the problem anyway.
If I restart runserver, I have again the right to read about 100 pages, but after it crashes.
The only solution I found is to remove django-debug-toolbar from settings.py : then total_connections is stable.

I guess django-debug-toolbar is not closing DB connections in some way : could you give me a workaround because your package is an absolute must.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions