Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion MySQL has gone away (again)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
jason kirtland  
View profile  
 More options Jun 8 2009, 10:49 am
From: jason kirtland <j...@discorporate.us>
Date: Mon, 08 Jun 2009 07:49:44 -0700
Local: Mon, Jun 8 2009 10:49 am
Subject: Re: [sqlalchemy] Re: MySQL has gone away (again)

Kamil Gorlo wrote:
> On Thu, Jun 4, 2009 at 4:20 PM, Michael Bayer<mike...@zzzcomputing.com> wrote:
>> the connection went from good to dead within a few seconds (assuming SQL
>> was successfully emitted on the previous checkout).   Your database was
>> restarted or a network failure occurred.

> There is no other option? I'm pretty sure that DB was not restarted,
> network failure is of course possible but still.. (this is the same
> LAN).

Another cause of "went away" messages is a query that exceeds the
configured memory resources on the server.  Taking a look at MySQL's
logs may shed more light & give hints for which buffers need tuning if
that's the problem.

> But, assuming this is external problem - is there any way to tell
> SQLAlchemy to try another connection for the same request (instead of
> returning HTTP 500 for user), or maybe other pooling strategy or even
> something else?

Yes, with a simple pool event listener you can ensure the liveliness of
connections before the pool hands them out for use.  Usage example is
attached.

Cheers,
Jason

class LookLively(object):
     """Ensures that MySQL connections checked out of the
        pool are alive."""

     def checkout(self, dbapi_con, con_record, con_proxy):
         try:
             try:
                 dbapi_con.ping(False)
             except TypeError:
                 dbapi_con.ping()
         except dbapi_con.OperationalError, ex:
             if ex.args[0] in (2006, 2013, 2014, 2045, 2055):
                 # caught by pool, which will retry with a new connection
                 raise exc.DisconnectionError()
             else:
                 raise

  mysql-away.py
2K Download

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.