On Jul 11, 2008, at 9:23 AM, Ryan Parrish wrote:

>
> Using SQLAlchemy 0.4.4
>
> I am having a problem with SQLAlchemy where after the application that
> uses SQLAlchemy has been sitting overnight and a user makes the first
> queries of the day thru the app that uses SA, SQLAlchemy throws an
> error saying 'MySQL server has gone away', which I understand the
> reason to be that my mysql server has cut the idle connections, but I
> have pool_recycle = 3600 set and I thought that was the solution to
> keeping connections alive?
>
> After that error message I get two more exceptions when the user tries
> the request again of "Can't reconnect until invalid transaction is
> rolled back", which I don't understand at all because the application
> only queries the DB and never deals with transactions.  After those
> three attempts, the forth request will go through just fine.  :-\  Any
> pointers on what I should look for or do?

this indicates your application has checked out a Connection from the  
pool and is keeping it open, in a transaction.   the connection then  
times out, and upon reaccess the next day would like to reconnect  
itself on next access; for a current Connection, this can reconnect  
its internal DBAPI connection transparently and you get to use the  
same Connection object.  But Connection won't allow you to do this if  
its in a transaction, i.e. begin(); when the disconnect exception is  
thrown, it expects that to be within a try/except block which will do  
a rollback on error.

The reason you're getting the disconnect exception in the first place  
is because the pool_recycle feature only works upon checkout from the  
pool.  So the solution is the same, ensure all connections are  
returned to the pool after operations are complete.


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

Reply via email to