Opened 3 years ago

Closed 3 years ago

#22060 closed Bug (duplicate)

Error with Postgresql persistent connections after DB fail/restart

Reported by: Connor23 Owned by: nobody
Component: Database layer (models, ORM) Version: 1.6
Severity: Normal Keywords: persistent, connection, psycopg2, postgresql, pool, db, database, error, fail
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no



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/", 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/", line 194, in __call__
  File "/srv/webapps/myapp/local/lib/python2.7/site-packages/django/dispatch/", line 185, in send
    response = receiver(signal=self, sender=sender, **named)
  File "/srv/webapps/myapp/local/lib/python2.7/site-packages/django/db/", line 94, in close_old_connections
  File "/srv/webapps/myapp/local/lib/python2.7/site-packages/django/db/backends/", 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/", 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:


CONN_MAX_AGE is set to 600

Is this a bug? Any ideas?

Change History (1)

comment:1 Changed 3 years ago by Tim Graham

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Resolution: duplicate
Status: newclosed

Duplicate of #21553 I think.

Note: See TracTickets for help on using tickets.
Back to Top