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) ...@@ -5,10 +5,15 @@ before = now - int(7)
strfstring = '%Y-%m-%d %H:%M:%S' 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 # Force reindexation of recently created document
# This expect module to use HBTree # 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",)): for module_id in portal.objectIds(("ERP5 Folder",)):
if module_id.endswith("_module"): if module_id.endswith("_module"):
portal[module_id].recurseCallMethod( portal[module_id].recurseCallMethod(
...@@ -22,23 +27,31 @@ for module_id in portal.objectIds(("ERP5 Folder",)): ...@@ -22,23 +27,31 @@ for module_id in portal.objectIds(("ERP5 Folder",)):
portal.ERP5Site_checkDeletedDocumentList(0, 1000, 100) portal.ERP5Site_checkDeletedDocumentList(0, 1000, 100)
for module_id in [
'portal_preferences', # Whenever we trust that the catalog is consistent and more recent them the
'portal_categories', # ZODB, it isn't required to trigger the whole reindexation of the site.
'portal_alarms',
'portal_simulation']+portal.objectIds(("ERP5 Folder",)): # If the Mariadb is eventually inconsitent or older them the current ZODB,
portal[module_id].recurseCallMethod( # It's required reindex the whole site.
'immediateReindexObject',
min_depth=1, if not optimistic:
max_depth=10000, for module_id in [
activate_kw=dict( 'portal_preferences',
group_method_id='portal_catalog/catalogObjectList', 'portal_categories',
alternate_method_id='alternateReindexObject', 'portal_alarms',
group_method_cost=1, 'portal_simulation']+portal.objectIds(("ERP5 Folder",)):
priority=6, portal[module_id].recurseCallMethod(
), 'immediateReindexObject',
max_retry=0, min_depth=1,
activity_count=100, 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" return "OK"
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string></string> </value> <value> <string>optimistic=True</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <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