persistent db connections and postgresql_psycopg2 InterfaceError

367 views
Skip to first unread message

Pavel Lurye

unread,
Dec 17, 2013, 10:38:48 AM12/17/13
to django...@googlegroups.com
Hi,
does anyone have used django1.6 persistent connections with postgresql?
I've done a simple test and I'm not sure, that django behaves correctly.
Django can't recover after DB restart, and all further db requests lead to server error:
---------------
Traceback (most recent call last):
  File "/venv/local/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 194, in __call__
    signals.request_started.send(sender=self.__class__)
  File "/venv/local/lib/python2.7/site-packages/django/dispatch/dispatcher.py", line 185, in send
    response = receiver(signal=self, sender=sender, **named)
  File "/venv/local/lib/python2.7/site-packages/django/db/__init__.py", line 95, in close_old_connections
    conn.close_if_unusable_or_obsolete()
  File "/venv/local/lib/python2.7/site-packages/django/db/backends/__init__.py", line 466, in close_if_unusable_or_obsolete
    if self.is_usable():
  File "/venv/local/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/base.py", line 196, in is_usable
    self.connection.cursor().execute("SELECT 1")
psycopg2.InterfaceError: connection already closed
---------------

So, InterfaceError is not catched by django in postgresql_psycopg2.DatabaseWrapper.is_usable.

My test environment is:
Ubuntu 13.10
postgresql 9.1

Django==1.6.1
psycopg2==2.5.1
uWSGI==1.9.21.1

Prashanth

unread,
Dec 17, 2013, 2:59:46 PM12/17/13
to django...@googlegroups.com

I suspect restarting your Web server will fix it as you'll get fresh connections. What is your CONN_MAX_AGE?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/77922966-a48e-4284-badd-e93f052fff54%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Pavel Lurye

unread,
Dec 18, 2013, 10:23:57 AM12/18/13
to django...@googlegroups.com
Hi,
CONN_MAX_AGE=None.
Of course, restarting will fix the problem, but that's not what I'm expecting from django.
I think this is django bug, but I want to be sure.

вторник, 17 декабря 2013 г., 18:59:46 UTC+4 пользователь Prashanth B написал:

Connor23

unread,
Feb 15, 2014, 10:40:53 PM2/15/14
to django...@googlegroups.com
I have a very similar configuration and I get the exact same error.

Have you open a ticket? Thanks.
Reply all
Reply to author
Forward
0 new messages