Commit 468b503b authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_erp5: [Data Recovery] Skip full reindexation if isn't needed

   If the mariadb is more recent (and consitent) them the ZODB, it isn't needed to full reindex since all
   changed objects are visible in the catalog. So it is safe enough only partially reindex.
parent e200fcad
Pipeline #16626 failed with stage
in 0 seconds
......@@ -5,10 +5,15 @@ before = now - int(7)
strfstring = '%Y-%m-%d %H:%M:%S'
portal.ERP5Site_checkLatestModifiedDocumentList(0, 1000, 100, before.strftime(strfstring), now.strftime(strfstring))
portal.ERP5Site_checkLatestModifiedDocumentList(0, 1000, 100,
before.strftime(strfstring), now.strftime(strfstring))
# Force reindexation of recently created document
# This expect module to use HBTree
# The following category could be consider as "non-optimistic", but
# it is minimal compared to a whole reindex and it is safe to prevent
# Minor inconsistencies.
for module_id in portal.objectIds(("ERP5 Folder",)):
if module_id.endswith("_module"):
portal[module_id].recurseCallMethod(
......@@ -22,23 +27,31 @@ for module_id in portal.objectIds(("ERP5 Folder",)):
portal.ERP5Site_checkDeletedDocumentList(0, 1000, 100)
for module_id in [
'portal_preferences',
'portal_categories',
'portal_alarms',
'portal_simulation']+portal.objectIds(("ERP5 Folder",)):
portal[module_id].recurseCallMethod(
'immediateReindexObject',
min_depth=1,
max_depth=10000,
activate_kw=dict(
group_method_id='portal_catalog/catalogObjectList',
alternate_method_id='alternateReindexObject',
group_method_cost=1,
priority=6,
),
max_retry=0,
activity_count=100,
)
# Whenever we trust that the catalog is consistent and more recent them the
# ZODB, it isn't required to trigger the whole reindexation of the site.
# If the Mariadb is eventually inconsitent or older them the current ZODB,
# It's required reindex the whole site.
if not optimistic:
for module_id in [
'portal_preferences',
'portal_categories',
'portal_alarms',
'portal_simulation']+portal.objectIds(("ERP5 Folder",)):
portal[module_id].recurseCallMethod(
'immediateReindexObject',
min_depth=1,
max_depth=10000,
activate_kw=dict(
group_method_id='portal_catalog/catalogObjectList',
alternate_method_id='alternateReindexObject',
group_method_cost=1,
priority=6,
),
max_retry=0,
activity_count=100,
)
return "OK"
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
<value> <string>optimistic=True</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
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