[repository] don't crash when cascading delete a relation, this may let the database in an inconsistent state anyway, so simply log the error stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 05 Nov 2010 09:18:48 +0100
branchstable
changeset 6674 fd9c76196bf7
parent 6673 5eb2f1f2c277
child 6675 12ee2fe13fa7
[repository] don't crash when cascading delete a relation, this may let the database in an inconsistent state anyway, so simply log the error
server/repository.py
--- a/server/repository.py	Fri Nov 05 09:17:43 2010 +0100
+++ b/server/repository.py	Fri Nov 05 09:18:48 2010 +0100
@@ -1120,9 +1120,13 @@
                     rql = 'DELETE Y %s X WHERE X eid %%(x)s' % rtype
                 if scleanup:
                     # source cleaning: only delete relations stored locally
-                    rql += ', NOT Y cw_source S, S name %(source)s'
-                session.execute(rql, {'x': eid, 'source': sourceuri},
-                                build_descr=False)
+                    rql += ', NOT (Y cw_source S, S name %(source)s)'
+                try:
+                    session.execute(rql, {'x': eid, 'source': sourceuri},
+                                    build_descr=False)
+                except:
+                    self.exception('error while cascading delete for entity %s '
+                                   'from %s. RQL: %s', entity, sourceuri, rql)
         self.system_source.delete_info(session, entity, sourceuri, extid)
 
     def locate_relation_source(self, session, subject, rtype, object):