#13215: Random OperationalError when using FastCGI prefork + PostgreSQL
-------------------------------------+--------------------------------------
          Reporter:  hcarvalhoalves  |         Owner:  jbronn
            Status:  assigned        |     Milestone:        
         Component:  Core framework  |       Version:  1.1   
        Resolution:                  |      Keywords:        
             Stage:  Accepted        |     Has_patch:  0     
        Needs_docs:  0               |   Needs_tests:  0     
Needs_better_patch:  0               |  
-------------------------------------+--------------------------------------
Changes (by jbronn):

  * owner:  nobody => jbronn
  * status:  new => assigned

Comment:

 Replying to [comment:1 russellm]:
 > In short, we need *anything* that can make this less random, and more
 repeatable.

 Russell, this problem is (unfortunately) easy to demonstrate and reproduce
 with GeoDjango.  It is much easier to do this on Linux than Mac OS X.

 1. Use
 [http://docs.djangoproject.com/en/dev/ref/contrib/gis/tutorial/#defining-a
 -geographic-model WorldBorders] model from the !GeoDjango tutorial

 2. Create a very simple view that conducts and configure a URL to go to
 it.  Here's what I did in `world.views` (note that it assumes you loaded
 the spatial data, see the tutorial):
 {{{
 from django.http import HttpResponse
 from world.models import WorldBorders

 def world_index(request):
     sm = WorldBorders.objects.get(name='San Marino')
     return HttpResponse(sm.mpoly.centroid.wkt)

 }}}

 3.  Use the following Lighttpd configuration (modify paths accordingly):
 {{{
 server.modules = (
   "mod_access",
   "mod_rewrite",
   "mod_fastcgi",
   "mod_accesslog",
 )
 server.document-root = "/home/geo/geodjango/media"

 server.port = 8000
 server.bind = "0.0.0.0"
 server.username = "geo"
 server.groupname = "geo"
 server.pid-file = "/home/geo/geodjango/var/lighttpd-fcgi.pid"
 static-file.exclude-extensions = (".fcgi", ".py", "~", )


 fastcgi.server = (
     "/geodjango.fcgi" => (
         "main" => (
             "socket" => "/home/geo/geodjango/var/geodjango.sock",
                 "check-local" => "disable",
         )
     ),
 )
 url.rewrite-once = (
      "^(/.*)$" => "/geodjango.fcgi$1",
 )

 accesslog.filename = "/home/geo/geodjango/var/geodjango.http.log"
 }}}

 4. Execute the `runfcgi` command, leave running in a spare terminal:
 {{{
 python manage.py runfcgi maxchildren=1 maxrequests=1
 socket=var/geodjango.sock daemonize=false debug=true
 }}}

 5. Visit the url for the view defined earlier (may work first time, but
 reload again).  You should get a psycopg2 `OperationalError`:
 {{{
  /django/trunk/django/db/backends/__init__.py  in
 _rollback(self=<django.contrib.gis.db.backends.postgis.base.DatabaseWrapper
 object at 0x10ce788>)
    34     def _rollback(self):
    35         if self.connection is not None:
    36             return self.connection.rollback()
    37
    38     def _enter_transaction_management(self, managed):
 self = <django.contrib.gis.db.backends.postgis.base.DatabaseWrapper object
 at 0x10ce788>, self.connection = None, self.connection.rollback undefined
 <class 'psycopg2.OperationalError'>: no connection to the server
       args = ('no connection to the server\n',)
       cursor = None
       message = 'no connection to the server\n'
       pgcode = None
       pgerror = None
 }}}

-- 
Ticket URL: <http://code.djangoproject.com/ticket/13215#comment:3>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

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

Reply via email to