Opened 5 weeks ago
Closed 5 weeks ago
#36534 closed New feature (needsinfo)
Problem Statement: Spike in PostgreSQL Connections After Upgrading Django from 3.2 to 5.2 Despite CONN_MAX_AGE = 10
Reported by: | ps018w | Owned by: | |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 5.2 |
Severity: | Release blocker | Keywords: | |
Cc: | ps018w | Triage Stage: | Unreviewed |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
After upgrading our Django application from version 3.2 to 5.2, we started observing unexpected spikes in active PostgreSQL database connections. This issue arises despite having CONN_MAX_AGE set to 10, which should allow persistent connections to be reused within a 10-second window, thereby preventing rapid connection churn.
Current Database Configuration:
DATABASES ={"default":env.db("DATABASE_URL",default="postgres://localhost/test"), }
DATABASESdefaultATOMIC_REQUESTS = False
DATABASESdefaultCONN_MAX_AGE = 10
The connection spike behavior was not observed prior to the upgrade, indicating a possible change in how Django 5.2 manages database connections, or a change in default behavior for connection pooling or request handling.
Thanks for the report. However, I don't think you've explained the issue in enough detail to confirm a bug in Django. 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.
Note that I see you have posted on the forum (https://forum.djangoproject.com/t/problem-statement-spike-in-postgresql-connections-after-upgrading-django-from-3-2-to-5-2-despite-conn-max-age-10/42146), I think it makes sense to provide more details on your project there and debug with the community to determine what is the cause of the spike.