From b81604f97396ece27d882f1975727f7e513e484c Mon Sep 17 00:00:00 2001 From: Andrew Egeler Date: Wed, 29 Nov 2023 14:15:46 -0500 Subject: [PATCH] Warn about persistent connection "feature" in Django 4.0+ Persistent database connections do not work in Django 4.0+ when running under ASGI; this caused a "too many database connections" problem that was difficult for me to find any information on. Since the ticket (https://code.djangoproject.com/ticket/33497) is marked as a feature and has been open for almost 2 years, I think it would be worth calling this scenario out in the documentation for anyone else who might hit it. --- docs/ref/databases.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/ref/databases.txt b/docs/ref/databases.txt index 8c5f877dfc..5dd3ad1515 100644 --- a/docs/ref/databases.txt +++ b/docs/ref/databases.txt @@ -40,6 +40,12 @@ database connection at the end of each request. To enable persistent connections, set :setting:`CONN_MAX_AGE` to a positive integer of seconds. For unlimited persistent connections, set it to ``None``. +.. warning:: + + Persistent connections :ticket:`do not work <33497>` when running Django + under ASGI. Setting :setting:`CONN_MAX_AGE` to anything other than ``0`` + may cause you to exceed your database connection limit. + Connection management ~~~~~~~~~~~~~~~~~~~~~