0

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:

  • Django==1.3.1
  • Django==1.3
  • psycopg2==2.4.2
  • psycopg2==2.4.1

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..

kirpit
  • 105
  • 5

1 Answers1

1

It is perhaps not about Python, Django, PostgreSQL, psycopg2 nor libsomething.so.

Check if you have option like --limit-as in your uWSGI configuration. On 64bit systems address space can be twice big.

kirpit
  • 105
  • 5
roberto
  • 1,827
  • 12
  • 8
  • Thank you for the answer @roberto. I guess the same that the problem is about address space on 64bit. Perhaps, I need to tweak somewhere in the some configuration file. But I'm not really sure what you mean by "--limit-as" option? – kirpit Nov 11 '11 at 04:22
  • limit-as is a uwsgi config value, I believe it default to 128MB of ram per worker. – David Apr 25 '13 at 22:22