[hooks/syncschema] do not crash on double removal of a constraint stable
authorAurelien Campeas <aurelien.campeas@logilab.fr>
Thu, 27 Feb 2014 18:10:29 +0100
branchstable
changeset 9559 072429be2d95
parent 9540 43b4895a150f
child 9560 97fed7743dbe
[hooks/syncschema] do not crash on double removal of a constraint Some complicated migrations may entail a double constraint removal. It is not yet known whether this is a genuine cw bug or the result of a complicated migration story, but we should nevertheless not crash. Rather, emit a CRITICAL warning and proceed. Closes #3595309.
hooks/syncschema.py
--- a/hooks/syncschema.py	Fri Feb 14 17:52:49 2014 +0100
+++ b/hooks/syncschema.py	Thu Feb 27 18:10:29 2014 +0100
@@ -676,7 +676,11 @@
         rdef = self.rdef
         # in-place modification of in-memory schema first
         _set_modifiable_constraints(rdef)
-        rdef.constraints.remove(self.oldcstr)
+        if self.oldcstr in rdef.constraints:
+            rdef.constraints.remove(self.oldcstr)
+        else:
+            self.critical('constraint %s for rdef %s was missing or already removed',
+                          self.oldcstr, rdef)
         # then update database: alter the physical schema on size/unique
         # constraint changes
         syssource = session.cnxset.source('system')