Commit 0587079a authored by Vincent Pelletier's avatar Vincent Pelletier

Tolerate indexing an object whose path is "deleted" in the catalog.

parent de98ee03
......@@ -86,23 +86,12 @@ class TestCopySupport(ERP5TypeTestCase):
self.assertTrue(person.getCareerSubordinationValue().aq_base is organisation.aq_base)
def test_02_unindexObjectDependency(self):
# XXX This test passes for bad reasons.
person = self.portal.person_module.newContent(portal_type='Person',
address_city='Lille')
self.tic()
person.recursiveReindexObject()
person.default_address.setId('old_address')
self.commit()
# Currently, the test passes only because ActivityTool.distribute always
# iterates on queues in the same order: SQLQueue before SQLDict.
# If Python returned dictionary values in a different order,
# reindex activities would fail with the following error:
# uid of <Products.ERP5Catalog.CatalogTool.IndexableObjectWrapper for
# /erp5/person_module/1/old_address> is 599L and is already assigned
# to deleted in catalog !!! This can be fatal.
# This test would fail if:
# - SQLDict was used for 'unindexObject'
# - there were more than MAX_VALIDATED_LIMIT unindexed & reindexed objects
self.tic()
def test_03_unindexObjectGrouping(self):
......
......@@ -1503,6 +1503,23 @@ class Catalog(Folder,
pass
finally:
lock.release()
elif catalog_path == 'deleted':
# Two possible cases:
# - Reindexed object's path changed (ie, it or at least one of its
# parents was renamed) but unindexObject was not called yet.
# Reindexing is harmelss: unindexObject and then an
# immediateReindexObject will be called.
# - Reindexed object was deleted by a concurrent transaction, which
# committed after we got our ZODB snapshot of this object.
# Reindexing is harmless: unindexObject will be called, and
# cannot be executed in parallel thanks to activity's
# serialisation_tag (so we cannot end up with a fantom object in
# catalog).
# So we index object.
# We could also not index it to save the time needed to index, but
# this would slow down all regular case to slightly improve an
# exceptional case.
pass
elif catalog_path is not None:
# An uid conflict happened... Why?
# can be due to path length
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment