Hi

I am using sqlalchemy0.5.5 in my TG2 app with mysql(innodb) database
My applicaton is multithreaded.
there are multiple tasks that run at certain intervals.
in one of my tables i am getting the following deadlock error.
Deadlock found when trying to get lock; try restarting transaction

the query was failing while trying to delete in the following way.
DBSession.query(Metrics).filter(Metrics.type_id==type_id).filter(Metrics.cdate
<= date1).delete()

so i changed the code to
rows =
DBSession.query(Metrics).filter(Metrics.type_id==type_id).filter(Metrics.cdate
<= date1).all()
for row in rows :
    DBSession.delete(row)
assuming that it will scan less no:of rows while deleting. In this way
i am no longer seeing the deadlock error.
but if anybody can clarify that this is reliable enough or suggest any
other options ,
that would be really helpful

thanks

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