From 2713e0aa65e05292be95b1ca93eb68073360aefb Mon Sep 17 00:00:00 2001
From: Vincent Pelletier <vincent@nexedi.com>
Date: Fri, 28 Dec 2007 15:04:22 +0000
Subject: [PATCH] Fix a race condition which can lead cells to being
 uncataloged when cell range is modified. It also fixes ZSQLCatalog from
 emmiting false "duplicate uid" warnings in this case.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@18549 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Type/XMLMatrix.py | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/product/ERP5Type/XMLMatrix.py b/product/ERP5Type/XMLMatrix.py
index 50819e6d8c..771e6ec9cb 100644
--- a/product/ERP5Type/XMLMatrix.py
+++ b/product/ERP5Type/XMLMatrix.py
@@ -285,6 +285,17 @@ class XMLMatrix(Folder):
             # Theses two lines are very important, if the object is renamed
             # then we must uncatalog the previous one
             o.unindexObject(path='%s/%s' % (self.getUrl() , object_id))
+            # Force a new uid to be allocated, because unindexObject creates
+            # an activity which will later delete lines from catalog based
+            # on their uid, and it is not garanted that indexation will happen
+            # after this deletion.
+            # It is bad to waste uids, but this data structure offers no
+            # alternative because cell id gives its index in the matrix,
+            # so reordering axes requires the cell id to change.
+            # XXX: It can be improved, but requires most of this file to be
+            # rewritten, and compatibility code must be written as data
+            # structure would most probably change.
+            o.uid = None
           o.reindexObject() # we reindex in case position has changed
                             # uid should be consistent
         else:
-- 
2.30.9