﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
31373	Django 3.x / uwsgi is leaking connections	Marcin Nowak	nobody	"Project upgraded from 2.x to 3.0.4 is leaking PostgreSQL database connections.
ATOMIC_REQUESTS=False, AUTOCOMMIT=True, CONN_MAX_AGE=0
UWSGi threads are enabled (`--enable-threads`)  
Python 3.8.1 and 3.7.3

After few hours all posgtress connections are used (too many connections error). 
pg_stat_activity is reporting idle connections with part of queries visible.
 
I would try to deliver more details later. 

[[Image(Firefox_Screenshot_2020-03-17T15-05-35.104Z.png)]]

Facts:
- setting up CONN_MAX_AGE > 0 does not help
- starting `runserver` and making many calls with `ab -c 10 -n 100 http://127.0.0.1:8000/` uses all available connections and ends with error 500 (due to no available connections)  
- starting `runserver --nothreading` and making calls with  `ab -c 100 -n 100 http://127.0.0.1:8000/` works fine

     "	Uncategorized	new	Uncategorized	3.0	Normal				Unreviewed	0	0	0	0	0	0
