Author: nunofsantos
Date: 2008-12-11 13:45:53 -0500 (Thu, 11 Dec 2008)
New Revision: 2978
Modified:
mgmt/trunk/mint/python/mint/sql.py
Log:
try 'select ... for update' to deal with deadlocks
Modified: mgmt/trunk/mint/python/mint/sql.py
===================================================================
--- mgmt/trunk/mint/python/mint/sql.py 2008-12-11 18:38:09 UTC (rev 2977)
+++ mgmt/trunk/mint/python/mint/sql.py 2008-12-11 18:45:53 UTC (rev 2978)
@@ -151,16 +151,22 @@
if table.endswith("_stats"):
parent_table = table[0:table.find("_stats")]
sql = """
+ select * from %s
+ where qmf_update_time < now() - interval '%%(threshold)s seconds'
+ for update;
delete from %s
where qmf_update_time < now() - interval '%%(threshold)s seconds'
- """ % table
+ """ % (table, table)
if self.keepCurrStats:
sql += " and id not in (select stats_curr_id from %s)" %
(parent_table)
else:
sql = """
+ select * from %s
+ where qmf_create_time < now() - interval '%%(threshold)s seconds'
+ for update;
delete from %s
where qmf_create_time < now() - interval '%%(threshold)s seconds'
- """ % table
+ """ % (table, table)
return sql
class SqlGetBrokerRegistration(SqlOperation):