InterfaceError: connection already closed

175 views
Skip to first unread message

Tim Zenderman

unread,
Jun 2, 2014, 4:50:40 PM6/2/14
to django...@googlegroups.com
It seems that after updating to 1.6, we are running into an InterfaceError on different views at random times. I found the some older tickets below where the issues is apparently resolved, but it's not in my case. Could this be related to the ATOMIC setting for postgres? What could I be doing in my code that is screwing with the DB connection?

The full stack trace is below. It seems to be happening while the request is starting that the DB connection has already been closed?

We are running this on:
Ubuntu 12.04

Django 1.6.5
Psycopg 2.5.3


  File "django/core/handlers/base.py", line 88, in get_response
    response = middleware_method(request)
  File "django/middleware/locale.py", line 32, in process_request
    request, check_path=check_path)
  File "django/utils/translation/__init__.py", line 166, in get_language_from_request
    return _trans.get_language_from_request(request, check_path)
  File "django/utils/translation/trans_real.py", line 430, in get_language_from_request
    lang_code = request.session.get('django_language', None)
  File "django/contrib/sessions/backends/base.py", line 58, in get
    return self._session.get(key, default)
  File "django/contrib/sessions/backends/base.py", line 173, in _get_session
    self._session_cache = self.load()
  File "django/contrib/sessions/backends/db.py", line 20, in load
    expire_date__gt=timezone.now()
  File "django/db/models/manager.py", line 151, in get
    return self.get_queryset().get(*args, **kwargs)
  File "django/db/models/query.py", line 304, in get
    num = len(clone)
  File "django/db/models/query.py", line 77, in __len__
    self._fetch_all()
  File "django/db/models/query.py", line 857, in _fetch_all
    self._result_cache = list(self.iterator())
  File "django/db/models/query.py", line 220, in iterator
    for row in compiler.results_iter():
  File "django/db/models/sql/compiler.py", line 713, in results_iter
    for rows in self.execute_sql(MULTI):
  File "django/db/models/sql/compiler.py", line 785, in execute_sql
    cursor = self.connection.cursor()
  File "django/db/backends/__init__.py", line 162, in cursor
    cursor = util.CursorWrapper(self._cursor(), self)
  File "django/db/backends/__init__.py", line 134, in _cursor
    return self.create_cursor()
  File "django/db/utils.py", line 99, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "django/db/backends/__init__.py", line 134, in _cursor
    return self.create_cursor()
  File "django/db/backends/postgresql_psycopg2/base.py", line 137, in create_cursor
    cursor = self.connection.cursor()


Thanks!
Tim

Tim Zenderman

unread,
Jun 4, 2014, 9:45:15 AM6/4/14
to django...@googlegroups.com
I have avoided the issue in the short term by not using ATOMIC_REQUESTS and going back to the 1.5 transaction middleware. What could possibly be in my code or project that does not sit well with ATOMIC_REQUESTS?

-Tim
Reply all
Reply to author
Forward
0 new messages