On Oct 31, 2011, at 8:45 AM, Benjamin Sims wrote:

> Hi all,
> 
> I'm seeing this error intermittently in my application since switching to 
> MySQL - it occurs on several different pages and I can't track down why:
> 
> StatementError: Can't reconnect until invalid transaction is rolled back 
> (original cause: InvalidRequestError: Can't reconnect until invalid 
> transaction is rolled back) 'SELECT [... the same select every time, which 
> gets a user from the database]

how are you handling threading, as well as Session lifecycle ?  this kind of 
error usually occurs from one of two things:  a. sharing Sessions, or objects 
attached to them, between threads or b. no clear point of Session start/end, 
incorrect handling of exceptions, etc.



> 
> I have searched on the error and read the various discussions, for example 
> this one:
> 
> http://groups.google.com/group/sqlalchemy/browse_thread/thread/a8031eefc4d5d0cd
> 
> My understanding is that somewhere in my code I need to be ensuring that I do 
> rollback/commit/close when the operation is complete. The problem is... 
> where? Is there a way I can get a log to see the original query/point in my 
> code which triggers the error.

sure you should turn on SQLAlchemy logging fully 
(http://www.sqlalchemy.org/docs/core/engines.html?highlight=logging#configuring-logging)
  , and also make sure you aren't squashing exceptions (i.e. except 
MyException, e: pass type of thing) - also you'd want to add code such as 
log.error("exception occurred", exc_info=True) to the point at which exceptions 
are caught so that a full stack trace is written out to the log.



-- 
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.

Reply via email to