Skip to content

[BUG] solrfal memory exhaustion during file indexing #4504

@kitzberger

Description

@kitzberger

Problem

File indexing crashes with "Allowed memory size exhausted" when processing more than a few files. In our case, indexing fails at around 2-3 files with the default 256M memory limit.

After investigating, I found that Indexer::getIsMergingEnabledFormItem() calls getSolrConfiguration() for every single file being indexed. This loads and parses the entire TypoScript configuration tree each time, which in our setup consumes ~330MB per file. Only to determine whether or not file duplicates should be merged.

The configuration value being retrieved is the same for all files from the same site, but there's no caching.

Current code (line ~262)

protected function getIsMergingEnabledFormItem(Item $item)
{
    $configuration = $item->getContext()->getSite()->getSolrConfiguration();
    $merge = $configuration->getValueByPathOrDefaultValue('plugin.tx_solr.index.enableFileIndexing.mergeDuplicates', false);
    return filter_var($merge, FILTER_VALIDATE_BOOLEAN);
}

Proposed fix

Cache the configuration value per site:

private array $mergeConfigCache = [];

protected function getIsMergingEnabledFormItem(Item $item)
{
    $siteRootPageId = $item->getContext()->getSite()->getRootPageId();
    
    if (isset($this->mergeConfigCache[$siteRootPageId])) {
        return $this->mergeConfigCache[$siteRootPageId];
    }
    
    $configuration = $item->getContext()->getSite()->getSolrConfiguration();
    $merge = $configuration->getValueByPathOrDefaultValue('plugin.tx_solr.index.enableFileIndexing.mergeDuplicates', false);
    
    $this->mergeConfigCache[$siteRootPageId] = filter_var($merge, FILTER_VALIDATE_BOOLEAN);
    return $this->mergeConfigCache[$siteRootPageId];
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions