I am having a weird production specific error related to Python psycopg2 postgresql driver and libgcrypt module.
I was running Debian 6, 32bit to host my application with uWSGI and Nginx. I decided to switch to 64bit with fresh install. Everything seemed fine except I am getting below Python traceback for every request in the uwsgi.log:
File ".../python2.7/site-packages/django/core/handlers/wsgi.py", line 272, in __call__ response = self.get_response(request) File ".../python2.7/site-packages/django/core/handlers/base.py", line 169, in get_response response = self.handle_uncaught_exception(request, resolver, sys.exc_info()) File ".../python2.7/site-packages/django/core/handlers/base.py", line 203, in handle_uncaught_exception return debug.technical_500_response(request, *exc_info) File ".../python2.7/site-packages/django/views/debug.py", line 59, in technical_500_response html = reporter.get_traceback_html() and so on...
So, I went to django/core/handlers/base.py (Django version 1.3.1) line 166 which seems the last exception handler that holds everything really exceptional. I replaced it with:
except Exception, why:
and write the "why" to a text file. The exception is exactly that:
Error loading psycopg2 module: libgcrypt.so.11: failed to map segment from shared object: Cannot allocate memory
I read almost every similar bug / issue / blogpost and could only find that one that believe not exactly same issue but quite similar: http://www.johngirvin.com/archives/dovecot-error-127-after-upgrading-to-debian-squeeze.html
I did try with:
also rebooted which gave no result. I have postgresql-8.4, libgcrypt11 and libgcrypt11-dev installed on the system. PostgreSQL has no model except a fresh ./manage.py syncdb with Django default ones. There is more than half of the memory is just empty.
And... I also tried to run ./manage.py runserver on production which works perfectly fine. The VPS is on Linode, so I don't think there is any hardware problem.
Any help will be appreciated.
[EDIT] well, after weeks problem still remains. I've moved the server to another machine in case if it was a hardware problem.. I also upgraded psycopg2 to version 2.4.4. Error message has been changed to
Error loading psycopg2 module: libgnutls.so.26: failed to map segment from shared object: Cannot allocate memory
libgnutls-dev is installed. Don't know what to do, can't use postgresql at all..