PHP Memory limit error during indexing

Created on 13 June 2024, 6 months ago
Updated 24 June 2024, 6 months ago

Problem/Motivation

The flag_indexer processor provided by the module could trigger memory limit error while indeixng contents, If the number of users who have flagged an entity is very large.

Error

Fatal error:  Allowed memory size of 1073741824 bytes exhausted (tried to allocate 20480 bytes) in /var/www/html/docroot/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php on line 599
Fatal error:  Allowed memory size of 1073741824 bytes exhausted (tried to allocate 20480 bytes) in /var/www/html/docroot/core/lib/Drupal/Core/Entity/EntityFieldManager.php on line 360

In my case, the website has large number of users. Most of the entities are flagged by 1000 plus users. During indexing, the flag_indexer processor calls

$this->flagService->getFlaggingUsers($entity, $flags[$flag_id]);

The method getFlaggingUsers() loads all the user entities associated with the content. The processor then loops through the user entities and stores the id of the user in the field.

          foreach ($users as $user) {
            $flag_field->addValue($user->id());
          }

This results in the memory limit error. I just want to render the flag field in the search api view. The view field plugin provided by the module does not required the user ids to render the flag. So as a temporary solution, I have commened the code in Drupal\flag_search_api\Plugin\search_api\processor\FlagIndexer::addFieldValues()

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

💬 Support request
Status

Closed: won't fix

Version

2.0

Component

Code

Created by

🇮🇳India Akhil Babu Chengannur

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @Akhil Babu
  • Status changed to Closed: won't fix 6 months ago
  • 🇭🇷Croatia xSDx

    This is something that needs to be resolved on the Flag module and not this one.

Production build 0.71.5 2024