try:
Perform table transaction
break
except:
rollback
delay
try again to perform table transaction
I'm sure you will get the gist of the above and why. I also set my
isolation_level to READ UNCOMMITED.
Thanks,
Garyc
--- On Thu, 5/6/10, rajasekhar911 <[email protected]> wrote:
> From: rajasekhar911 <[email protected]>
> Subject: [sqlalchemy] how to handle deadlock
> To: "sqlalchemy" <[email protected]>
> Date: Thursday, May 6, 2010, 5:23 AM
> 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 [email protected].
> 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.
>
>
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected].
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.