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.

Issue fork search_api-3030868

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

juandeleon created an issue. See original summary.

avpaderno’s picture

Priority: Major » Normal
acbramley’s picture

Category: Support request » Bug report

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

acbramley’s picture

Status: Active » Needs review
drunken monkey’s picture

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 #3396064: (Try to) fix the GitLab CI 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.)

bramdriesen’s picture

Status: Needs review » Reviewed & tested by the community

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.

drunken monkey’s picture

Status: Reviewed & tested by the community » Fixed

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

Status: Fixed » Closed (fixed)

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