On Nov 14, 2012, at 2:38 PM, JonathanQ wrote: > We have some code running against MySQL running in Amazon RDS. During an > outage or the maintenance window - Amazon issues an automatic failover of our > RDS instance. However our code doesn't failover with it. > > We are having issues with 2 of our applications (2 different issues): > > First one: Unable to rollback when we get the error "2006, 'MySQL server has > gone away'" > > The issue we are having is that a DB operation will fail when the failover > occurs. So in the event of an error we issue a rollback on the SqlSoup > object (which delegates to the underlying session). > > sqlsoup_engine.rollback() > > However this rollback fails with the error: > > connection.rollback() > OperationalError: (OperationalError) (2006, 'MySQL server has gone away') > None None > > Subsequently our application continues on an then starts failing with: > StatementError("Can't reconnect until invalid transaction is rolled back > (original cause: InvalidRequestError: Can't reconnect until invalid > transaction is rolled back)",)
OK well when you say "in the event of an error", is that an error that precedes the rollback, and is it the same 2006 error ? or is the 2006 error new with the rollback? Basically, what should happen is, any DB operation, like execute, or commit, rollback, can potentially throw a 2006. SQLAlchemy will detect this as a "disconnect" situation, and discard all open connections that aren't checked out. The next operation will use a brand new connection. So without knowing if you're getting this same error multiple times or not, you'd want to either rollback() a second time, or just throw away the Session after the rollback() fails. With SQLSoup you'd want to get at it by sqlsoup_engine.session.remove(), which will replace the current thread's Session with a new one. -- 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 sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.