Comment 5 for bug 850770

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

Well, I think I have _some_ idea what's going on, although not much. Basically, the problem is that the _psycopg module has a process global dictionary of adapters, including the adapter for Decimal types. mod_wsgi runs all the various WSGI apps it is hosting in one process (or at least only a small number of processes) and so if one WSGI app messes with this adapter registry somehow, all the other hosted WSGI apps will break. I don't know which app we're hosting could do this, but _possibly_ it's the edge site. I notice that the edge .wsgi file uses the "activate_this" script from the virtualenv, but this is a bad idea with mod_wsgi:

http://code.google.com/p/modwsgi/wiki/VirtualEnvironments

It's possible that some of the manipulations activate_this does mean that importing the decimal module will fail, and if another app is unlucky enough to import psycopg2 module at this moment psycopg2 for that process forever more will not support decimals. This seems moderately unlikely, but it's the best guess I have.

Fixes that suggest themselves, in increasing order of invasiveness but also perhaps desirability:

1) Change the edge .wsgi script to not use activate_this.py
2) Switch to using mod_wsgi in daemon mode
3) Stop using mod_wsgi at all and ProxyPass to gunicorn or something.