Changeset 15748


Ignore:
Timestamp:
4 Nov 2019, 10:15:44 (5 years ago)
Author:
uli
Message:

Bad workaround to cope with overcrowded catalogs.

Zope does not cope well with catalogs of more than 500.000 elements.
Reindexing the catalog then means to put all objects into memory before
saving them - this can blow everything.

We therefore use a dirty hack to replace the updateIndex method of
a catalog with a more careful function, that, however, should not be
run in production mode. No new items should be added during the run.

In the long run, we certainly need something more sustainable.

Location:
main/waeup.kofa/trunk/src/waeup/kofa
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/hostels/hostel.py

    r15741 r15748  
    345345            if 'bed_id' not in cat.keys():
    346346                nothing_to_do = False
     347                # replace original `updateIndex` method
     348                def updateIndexReplacement(index):
     349                    reindex_cat(cat)
     350                cat._updateIndex = cat.updateIndex
     351                cat.updateIndex = updateIndexReplacement
     352                # setup catalog
    347353                cat[u'bed_id'] = FieldIndex(field_name=u'bed_id')
     354                cat.updateIndex = cat._updateIndex  # undo changes
    348355                logger.info(
    349356                    '%s: bed_id index added to beds_catalog.'
  • main/waeup.kofa/trunk/src/waeup/kofa/utils/helpers.py

    r15739 r15748  
    2727import shutil
    2828import tempfile
     29import transaction
    2930import grok
    3031from cStringIO import StringIO
     
    956957    uids = get_catalog_docids(cat)
    957958    print("Found %s entries..." % len(uids))
    958     for docid in uids:
     959    for n, docid in enumerate(uids):
    959960        ob = uidutil.getObject(docid)
    960961        cat.index_doc(docid, ob)
     962        # indexes can become huge. commit changes every 5000th round to
     963        # keep the memory footprint of catalogs `updateIndex` manageable
     964        if not n % 5000:
     965            transaction.commit()
    961966    d2 = datetime.datetime.now()
    962967    print("Finished. %s" % (d2 - d1))
Note: See TracChangeset for help on using the changeset viewer.