Item tracking causing out of memory in deployments

Created on 5 February 2019, about 6 years ago
Updated 29 January 2024, about 1 year ago

Somehow it looks like my deployments are breaking as there are pending items to be indexed:

 [37;46;1m[notice][39;49;22m Synchronized configuration: update block.block.views_block__search_block_3.
 [37;46;1m[notice][39;49;22m Synchronized configuration: update block.block.views_block__search_block_2.
 [37;46;1m[notice][39;49;22m Synchronized configuration: update block.block.exposedformsearchpage_2.
 [37;46;1m[notice][39;49;22m Synchronized configuration: update acquia_connector.settings.
 [37;46;1m[notice][39;49;22m Synchronized configuration: update config_split.config_split.test.
 [37;46;1m[notice][39;49;22m Synchronized configuration: update project_events_importer.nextsince.
 [37;46;1m[notice][39;49;22m Tracking items for search index <em class="placeholder">Content</em> (1 of 1)
 [37;46;1m[notice][39;49;22m Tracking items for search index <em class="placeholder">Content</em> (1 of 1)
 [37;46;1m[notice][39;49;22m Tracking items for search index <em class="placeholder">Content</em> (1 of 1)

... and 2,370 items later...

[37;46;1m[notice][39;49;22m Tracking items for search index <em class="placeholder">Content</em> (1 of 1)
 [37;46;1m[notice][39;49;22m Tracking items for search index <em class="placeholder">Content</em> (1 of 1)
 [37;46;1m[notice][39;49;22m Tracking items for search index <em class="placeholder">Content</em> (1 of 1)

Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 24576 bytes) in /mnt/www/html/myproject/docroot/core/lib/Drupal/Core/Database/Statement.php on line 59

Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 65536 bytes) in /mnt/www/html/myproject/vendor/drush/drush/src/Boot/DrupalBoot8.php on line 261
[Acquia\Blt\Robo\Tasks\DrushTask]  Exit code 255  Time 05:22
[error]  Failed to import configuration! 
[error]  Command `drupal:config:import ` exited with code 1. 

According to the Status report, I have over 50k+ pending Search API tasks. I have disabled and re-enabled the index to track items and reindex from scratch but when I do it:

myproject@staging-30580:/var/www/html/myprojectstg$ drush search-api-enable acquia_search_index -vvv
 [preflight] Config paths: /etc/drush/drush.yml,/mnt/www/html/myprojectstg/vendor/drush/drush/drush.yml,/mnt/www/html/myprojectstg/drush/drush.yml
 [preflight] Alias paths: /mnt/drush/myproject,/mnt/www/html/myprojectstg/docroot/drush/sites,/var/www/html/myprojectstg/drush/sites
 [preflight] Commandfile search paths: /mnt/www/html/myprojectstg/vendor/drush/drush/src,/etc/acquiadrush/commands,/mnt/www/html/myprojectstg/drush
 [debug] Bootstrap further to find search-api-enable
 [debug] Trying to bootstrap as far as we can
 [bootstrap] Drush bootstrap phase: bootstrapDrupalRoot()
 [bootstrap] Change working directory to /mnt/www/html/myprojectstg/docroot
 [bootstrap] Initialized Drupal 8.5.8 root directory at /mnt/www/html/myprojectstg/docroot
 [bootstrap] Drush bootstrap phase: bootstrapDrupalSite()
 [bootstrap] Initialized Drupal site default at sites/default
 [bootstrap] Drush bootstrap phase: bootstrapDrupalConfiguration()
 [debug] Add service modifier
 [info] sql-query: SELECT 1;
 [info] Executing: mysql --defaults-file=/mnt/tmp/myprojectstg/drush_mBErIy --database=myprojectstg --host=staging-30580 --port=3306 --silent -A < /mnt/tmp/myprojectstg/drush_6HpmhZ > /dev/null
 [info] sql-query: SELECT 1 FROM key_value LIMIT 1;
 [info] Executing: mysql --defaults-file=/mnt/tmp/myprojectstg/drush_A0HnEH --database=myprojectstg --host=staging-30580 --port=3306 --silent -A < /mnt/tmp/myprojectstg/drush_EE8ob8 > /dev/null
 [bootstrap] Drush bootstrap phase: bootstrapDrupalDatabase()
 [bootstrap] Successfully connected to the Drupal database.
 [bootstrap] Drush bootstrap phase: bootstrapDrupalFull()
 [debug] Start bootstrap of the Drupal Kernel.
 [debug] Finished bootstrap of the Drupal Kernel.
 [debugnotify] Add a commandfile class: Drush\Drupal\Commands\config\ConfigCommands
 [debugnotify] Add a commandfile class: Drush\Drupal\Commands\config\ConfigExportCommands
 [debugnotify] Add a commandfile class: Drush\Drupal\Commands\config\ConfigImportCommands
 [debugnotify] Add a commandfile class: Drush\Drupal\Commands\core\BatchCommands
 [debugnotify] Add a commandfile class: Drush\Drupal\Commands\core\CliCommands
 [debugnotify] Add a commandfile class: Drush\Drupal\Commands\core\DrupalCommands
 [debugnotify] Add a commandfile class: Drush\Drupal\Commands\core\EntityCommands
 [debugnotify] Add a commandfile class: Drush\Drupal\Commands\core\ImageCommands
 [debugnotify] Add a commandfile class: Drush\Drupal\Commands\core\LanguageCommands
 [debugnotify] Add a commandfile class: Drush\Drupal\Commands\core\LocaleCommands
 [debugnotify] Add a commandfile class: Drush\Drupal\Commands\core\MessengerCommands
 [debugnotify] Add a commandfile class: Drush\Drupal\Commands\core\QueueCommands
 [debugnotify] Add a commandfile class: Drush\Drupal\Commands\core\RoleCommands
 [debugnotify] Add a commandfile class: Drush\Drupal\Commands\core\StateCommands
 [debugnotify] Add a commandfile class: Drush\Drupal\Commands\core\TwigCommands
 [debugnotify] Add a commandfile class: Drush\Drupal\Commands\core\UserCommands
 [debugnotify] Add a commandfile class: Drush\Drupal\Commands\core\ViewsCommands
 [debugnotify] Add a commandfile class: Drush\Drupal\Commands\core\WatchdogCommands
 [debugnotify] Add a commandfile class: Drush\Drupal\Commands\pm\PmCommands
 [debugnotify] Add a commandfile class: Drush\Drupal\Commands\pm\ThemeCommands
 [debugnotify] Add a commandfile class: Drush\Drupal\Commands\sql\SanitizeCommands
 [debugnotify] Add a commandfile class: Drush\Drupal\Commands\sql\SanitizeCommentsCommands
 [debugnotify] Add a commandfile class: Drush\Drupal\Commands\sql\SanitizeSessionsCommands
 [debugnotify] Add a commandfile class: Drush\Drupal\Commands\sql\SanitizeUserFieldsCommands
 [debugnotify] Add a commandfile class: Drush\Drupal\Commands\sql\SanitizeUserTableCommands
 [debugnotify] Add a commandfile class: Drupal\config_split\Commands\ConfigSplitCommands
 [debugnotify] Add a commandfile class: Drupal\devel\Commands\DevelCommands
 [debugnotify] Add a commandfile class: Drupal\lightning_core\Commands\Hooks
 [debugnotify] Add a commandfile class: Drupal\lightning_core\Commands\LightningCoreCommands
 [debugnotify] Add a commandfile class: Drupal\lightning_scheduler\Commands\MigrationCommands
 [debugnotify] Add a commandfile class: Drupal\migrate_manifest\Commands\MigrateManifestCommands
 [debugnotify] Add a commandfile class: Drupal\migrate_tools\Commands\MigrateToolsCommands
 [debugnotify] Add a commandfile class: Drupal\search_api\Commands\SearchApiCommands
 [debugnotify] Add a commandfile class: Drupal\views_bulk_operations\Commands\ViewsBulkOperationsCommands
 [debug] Done with bootstrap max in Application::find(): trying to find search-api-enable again.
 [bootstrap] Starting bootstrap to none [0.41 sec, 30.93 MB]
 [bootstrap] Drush bootstrap phase 0 [0.41 sec, 30.93 MB]
 [bootstrap] Try to validate bootstrap phase 0 [0.41 sec, 30.93 MB]

And here the process is stuck and memory and CPU usage starts to increase, causing performance issues.

Does anyone have an insight on how could I process the pending items in batches so it doesn't consume all of my resources? I'm using BLT/Lightning and Acquia Cloud.

๐Ÿ› Bug report
Status

Active

Version

1.0

Component

General code

Created by

๐Ÿ‡ฒ๐Ÿ‡ฝMexico juandeleon

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

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia acbramley

    Just encountered this when adding a new index to a site that tracks revisions. This ends up at over 100k items to track. This isn't something that should be done during config sync. Luckily there's a pretty simple kill switch we can add

  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 10.1.4 + Environment: PHP 8.2 & sqlite-3.34
    last update about 1 year ago
    Composer require-dev failure
  • Status changed to Needs review about 1 year ago
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia acbramley
  • Pipeline finished with Failed
    about 1 year ago
    Total: 45s
    #83898
  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 10.1.4 + Environment: PHP 8.2 & sqlite-3.34
    last update about 1 year ago
    Composer require-dev failure
  • Pipeline finished with Failed
    about 1 year ago
    Total: 44s
    #84475
  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 10.1.4 + Environment: PHP 8.2 & sqlite-3.34
    last update about 1 year ago
    547 pass
  • ๐Ÿ‡ฆ๐Ÿ‡นAustria drunken monkey Vienna, Austria

    Thanks for suggesting that change, and sorry I didnโ€™t see this earlier.
    Not starting to track items during a config sync does sound reasonable, yes. Further up, in preSave(), we also check for $this->isInstallingFromExtension(). Would you say we should skip tracking in that case, too?

    In general, it seems like the assumption that a CLI (Drush) process wonโ€™t have any problems tracking an arbitrary large number of items in a single process seems a bit optimistic. Maybe we should stop after a certain number even in CLI? Otherwise, I guess we might run into the same problem in other contexts as well.
    However, probably better to first deploy the simpler option, we could discuss the general limit in a follow-up.

    Also, still need to use patches, unfortunately, but will probably merge ๐Ÿ“Œ (Try to) fix the GitLab CI RTBC in a week or so. I would just love to get it working in one of my smaller modules first, but that seems unlikely now.
    I also took the opportunity to fix the line length. (And use getContainer() since my IDE doesnโ€™t understand the other one, unfortunately.)

  • Status changed to RTBC about 1 month ago
  • ๐Ÿ‡ง๐Ÿ‡ชBelgium BramDriesen Belgium ๐Ÿ‡ง๐Ÿ‡ช

    We also bumped into this with a very large index (8 MIL items). I think it makes sense to not do this on config sync.

  • Pipeline finished with Success
    about 1 month ago
    Total: 443s
    #410745
  • Pipeline finished with Skipped
    about 1 month ago
    #413593
  • ๐Ÿ‡ฆ๐Ÿ‡นAustria drunken monkey Vienna, Austria

    Thanks for the feedback, good to hear this works.
    Added my tiny change from #6 to the MR and merged.
    Thanks again, everyone!

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024