[storm] Storm and MySQL in WSGI environment - MySQL server run away

Steve Kieu msh.computing at gmail.com
Wed Jan 26 11:54:11 UTC 2011


Hi,

It is more complicated than that though

Here is the entry point which is a method of my application

from webob import Request, Response, exc
class WebNoteApp(object):

def __call__(self, environ, start_response):

      req = Request(environ)
      req.charset = 'utf8' # Force to use Unicode
      action = req.params.get('action', 'show_frontpage')
      if ( req.cookies.get('authenticated', '0') == '0' and action !=
'do_login' ):
        action = 'show_login'
      try:
          try:
              #meth = getattr(self, 'action_%s_%s' % (str(action),
req.method) )
              meth = getattr(self, 'action_%s' % str(action)  )
          except AttributeError:
              raise exc.HTTPBadRequest('No such action %r' %
action).exception
          resp = meth(req)
      except exc.HTTPException, e:
          resp = e
      return resp(environ, start_response)

##

As you can see the method call is already in try: except - I do not process
if it failed yet but seems it just bomb out with 500 rather than going into
the code res = e

the meth (not listed here) will call a model object and model contains
several Storm objects. I even try to reload the model in the __init__ of the
Webnote class but it is still flaky, it work , sometimes it work some time
got error but reload will work (improvement compared with before that it
never recover until restart apache).

For now the most reliable way is cgi with slowness.




On Wed, Jan 26, 2011 at 9:20 PM, Jamu Kakar <jkakar at kakar.ca> wrote:

> Hi Steve,
>
> On Wed, Jan 26, 2011 at 10:00 AM, Steve Kieu <msh.computing at gmail.com>
> wrote:
> > Thanks for the answer.
> >
> > The problem is that when create a Store object, storm does not try to
> > connect right away so no exception is thrown at that point. When there is
> a
> > need, storm try to use the connection and fail. To handle it, I have to
> wrap
> > many try: catch exception all over places and not quite sure where and it
> > does not look good.
>
> In most cases you need one try/except at the place where you
> application starts processing the request.  Something like:
>
> def receive_request_from_web_server(request, retries=3):
>    try:
>        handle_request(request)
>    except DisconnectionError:
>        if retries:
>            # Probably want to sleep for a few seconds here, to give
>            # the database a chance to recover
>            receive_request_from_web_server(request, retries - 1)
>        else:
>            raise
>
> def handle_request(request):
>    # Application logic for the request
>
> > Like a php mysql db, they just don't care, if connection goes away, they
> > reconnect / make new connection automatically. That would be be nice
>
> That's not really possible with transactions.  You need to start a new
> transaction and perform your operation from scratch.
>
> Thanks,
> J.
>



-- 
Steve Kieu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/storm/attachments/20110126/fbba86e4/attachment-0001.html>


More information about the storm mailing list