hanging django/postgres idle connections

433 views
Skip to first unread message

Jani Kajala

unread,
Jul 30, 2014, 10:41:58 AM7/30/14
to django...@googlegroups.com
Hi,

I have a problem with leaking Postgres DB connections even if I have CONN_MAX_AGE=0. Every time I start the server and stop it by Ctrl+Break a DB connection is leaked.

When I check from Postgres there is bunch of "idle" connections with following content:
SELECT "django_migrations"."app", "django_migrations"."name" FROM "django_migrations"

I'm running Python on Windows 8 + virtualenv with following installs:
Django==1.7c1
future==0.12.4
psycopg2==2.5.3
python3-memcached==1.51
pytz==2014.4
six==1.7.3
sqlparse==0.1.11
virtualenv==1.11.6
xlwt-future==0.8.0

Postgres is running in Ubuntu 14.04 in latest Oracle VirtualBox on same Windows machine.

Any ideas?


Thanks,
Jani

cmawe...@gmail.com

unread,
Jul 31, 2014, 11:58:41 AM7/31/14
to django...@googlegroups.com
Does it work fine on django 1.6? It could be a regression.

Jani Kajala

unread,
Aug 1, 2014, 9:41:53 AM8/1/14
to django...@googlegroups.com
Haven't tried (yet), I'm new to Python & Django & Postgres, got on board with Python 3.4.1 and Django 1.7c1. I'm starting to suspect this isn't really Django related directly, since I can consistently reproduce the problem following way: 1) Run e.g. test case, break it in debugger 2) Stop debug session. Django cannot really do anything about me interrupting the debugging session, but it should not block access to DB indefinitely. However, it does. I tried also to install pgbouncer, but it made interestingly situation worse, now even a single connection can block access to DB even if I have pgbouncer max_connections set to 100. So maybe this is something Windows/VirtualBox networking related.

Jon Sandness

unread,
Nov 23, 2015, 4:36:23 PM11/23/15
to Django users
I'm seeing this same issue in OS X 10.11.1 - interestingly, the hang only occurs when I run migrations through Jenkins.  If I manually run the command inside of a VirtualBox session, it works as expected.

Jon

Ryan Bagwell

unread,
Mar 30, 2016, 12:27:20 PM3/30/16
to Django users
I'm also seeing this in two of our apps. Has anybody figured out a solution? Running Django 1.7.11.

HZ                    branding. advertising. digital. integrated. 
DC METRO     10101 molecular drive, suite 300, rockville, maryland 20850 | 301-294-6302
NEW YORK     298 fifth avenue, 2nd floor, new york, new york 10001 |  646-454-9206
BALTIMORE   1429 aliceanna street, 3rd floor, baltimore, maryland 21231 | 443-990-1834
BAY AREA       725 front street, suite 206, santa cruz, california 95060 | 831-421-9017
hzdg.com facebook.com/hzdg  | follow us @hzdg

Andrew Grigorev

unread,
Apr 28, 2016, 9:21:18 PM4/28/16
to Django users
Same problem with postgis database backend when running a development server.

среда, 30 июля 2014 г., 17:41:58 UTC+3 пользователь Jani Kajala написал:
Reply all
Reply to author
Forward
0 new messages