On Nov 5, 2010, at 1:33 AM, Lenza McElrath wrote:

> Interesting.  When I use your simple engine I do not get the error either, 
> but I definitely get it when using my real configuration.  We are using a 
> connection pool.  So the construction of the session maker for the test looks 
> like this:
> 
> e = sqlalchemy.create_engine('mysql://', pool=connections.get_pool())
> sessionmaker = sqlalchemy.orm.sessionmaker(e)
> 
> The connection pool is somewhat complex, so I will try to find the simplest 
> possible pool that reproduces the problem.  But, do you have ideas based on 
> this?  The script only fails when I use a Float type with a test_value that 
> is higher percision than the DB can represent.  It works when I use an 
> Integer type, or when test_value is 44 or 0.44.

The only cause for StaleDataError is if a flush() attempts to UPDATE the row 
indicated by "self.row_id", and that row is no longer present such that it 
returns an unexpected rowcount for the statement.   This can only occur if you 
have some other thread, process, or non-ORM instruction which deletes or 
changes the primary key of the target row in between when you loaded the object 
and when you flushed it.   If changing the Float precision is the trigger, then 
that change is causing something else to occur in your real application which 
causes the primary key to not be present.    MySQL is an extremely buggy 
database so its well within the realm of possibility that using the too-large 
float value is causing some incongruous condition to occur as well.    If this 
were the case, the key to isolating such issues with MySQL is to create a SQL 
script that reproduces the issue, i.e. that the ultimate UPDATE statement 
doesn't update the row as expected.  The echo output of your application and 
test script is a good place to start.




-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@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