﻿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
22060	Error with Postgresql persistent connections after DB fail/restart	Connor23	nobody	"Hi,

When using persistent connections with PostgreSQL if the DB fails or is restarted Django will return the following error:

{{{
2014-02-15 14:33:07 [24868] [ERROR] Error handling request
Traceback (most recent call last):
  File ""/srv/webapps/myapp/local/lib/python2.7/site-packages/gunicorn/workers/sync.py"", line 131, in handle_request
    respiter = self.wsgi(environ, resp.start_response)
  File ""/srv/webapps/myapp/local/lib/python2.7/site-packages/django/core/handlers/wsgi.py"", line 194, in __call__
    signals.request_started.send(sender=self.__class__)
  File ""/srv/webapps/myapp/local/lib/python2.7/site-packages/django/dispatch/dispatcher.py"", line 185, in send
    response = receiver(signal=self, sender=sender, **named)
  File ""/srv/webapps/myapp/local/lib/python2.7/site-packages/django/db/__init__.py"", line 94, in close_old_connections
    conn.close_if_unusable_or_obsolete()
  File ""/srv/webapps/myapp/local/lib/python2.7/site-packages/django/db/backends/__init__.py"", line 462, in close_if_unusable_or_obsolete
    if self.is_usable():
  File ""/srv/webapps/myapp/local/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/base.py"", line 192, in is_usable
    self.connection.cursor().execute(""SELECT 1"")
InterfaceError: connection already closed

}}}

Not sure if this is Django related or psycopg2 related.



Here are few details about my configuration:

Django==1.6.2
gunicorn==18.0
psycopg2==2.5.2


CONN_MAX_AGE is set to 600

Is this a bug? Any ideas?"	Bug	closed	Database layer (models, ORM)	1.6	Normal	duplicate	persistent, connection, psycopg2, postgresql, pool, db, database, error, fail		Unreviewed	0	0	0	0	0	0
