On Wed, Mar 2, 2011 at 11:46 PM, onelson <onel...@gmail.com> wrote:
> I recently switched a project from mysql to postgres and started to
> see httpd throwing intermittent 500 errors.
>
> mod_wsgi (pid=26467): Exception occurred processing WSGI script '..../
> htdocs/django.wsgi'.
>  Traceback (most recent call last):
>   File "...../lib/python2.6/site-packages/django/core/handlers/
> wsgi.py", line 275, in __call__
>     signals.request_finished.send(sender=self.__class__)
>   File "...../lib/python2.6/site-packages/django/dispatch/
> dispatcher.py", line 172, in send
>     response = receiver(signal=self, sender=sender, **named)
>   File "...../lib/python2.6/site-packages/django/db/__init__.py",
> line 84, in close_connection
>     conn.close()
>   File "...../lib/python2.6/site-packages/django/db/backends/
> __init__.py", line 79, in close
>     self.connection.close()
> InterfaceError: connection already closed
>
> I'm seeing this maybe every 20-30th page request.
>
> Looking at the issues on trac, I see a handful of tickets that share
> this error, however I don't see anything common between them (or my
> own situation) beyond using psycopg2.
> http://code.djangoproject.com/search?q=InterfaceError+connection+already+closed&noquickjump=1&ticket=on
> Most of the tickets are *old*. Years old. Either this is something pg
> users are familiar with and just know how to deal with, or this is a
> bug (or both?)

You're missing the third, and more likely option -- there's something
wrong with your code. I've been running MySQL and Postgres installs
for many years, and I've never encountered the problem you describe.
This isn't a case of "oh, that just happens and we live with it".

It's also possible that you have found a bug, but it's an edge case
particular to your particular usage. Looking at your stack trace,
you're getting the exception at the end of request processing when
Django tries to 'clean up' and close the connection to the database.
However, at that point, the database has already been closed. This
means that either:

 * You have already (implicitly or explicitly) closed the connection
 * The database connection has dropped out for some reason
 * The 'end of request' signal has been fired twice.

Absent of any specific details, I can't narrow down the problem any
more than that. We would need to see some specific code to give any
more advice. If you can reduce your code to a minimal test case that
demonstrates the problem, that might help.

Yours,
Russ Magee %-)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to