cron should not wait for suggester builds to succeed

Created on 20 December 2023, 6 months ago
Updated 17 April 2024, 2 months ago

Respect the submission guidelines above! Drupal.org issue forks cause additional work for the project maintainer!

Setup

  • Solr version: 8.11.2
  • Drupal Core version: 10.1.7
  • Search API version: 1.31.0
  • Search API Solr version: 4.3.1
  • Configured Solr Connector: Standard

Issue

Since updating to 4.3.0, we are seeing this error in Watchdog on every cron run:

Drupal\search_api_solr\SearchApiSolrException while maintaining Solr server Solr: Solr endpoint http://solr.internal:8983/ internal Solr server error (code: 0, body: , message: Solr HTTP error: HTTP request failed, Operation timed out after 5001 milliseconds with 0 bytes received). in Drupal\search_api_solr\SolrConnector\SolrConnectorPluginBase->handleHttpException() (line 1089 of /var/www/html/web/modules/contrib/search_api_solr/src/SolrConnector/SolrConnectorPluginBase.php).

The timeout is caused by the changes in ✨ Increase indexing performance by offloading suggester builds to cron Fixed -- suggest.buildAll takes ~130 seconds in our environment (>40 languages, >73,000 indexed items). We still have buildOnCommit enabled which seems to perform "fine".

I'm not sure what the best solution is--I suppose adding a configuration option whether to "build all" suggester during cron?

✨ Feature request
Status

Fixed

Version

4.3

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States mediabounds

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

Comments & Activities

  • Issue created by @mediabounds
  • πŸ‡©πŸ‡ͺGermany mkalkbrenner πŸ‡©πŸ‡ͺ

    Are you using the suggester? If not, you should turn it off in the Search API Server settings.

    buildOnCommit slows down reindexing significantly. That's why it has been offloaded to cron. But you can increase the index timeout in the Search API Server settings.

  • πŸ‡©πŸ‡ͺGermany mkalkbrenner πŸ‡©πŸ‡ͺ
  • πŸ‡ΊπŸ‡ΈUnited States mediabounds

    Yes, we do use suggester.

    In our Search API server settings, we currently have the timeouts configured as follows:
    - Query timeout: 5 seconds
    - Index timeout: 10 seconds
    - Optimize timeout: 10 seconds
    - Finalize timeout: 30 seconds

    As of 4.3.0, the addition of the suggest.buildAll query during cron is using the Query timeout. I would have to increase that to over 130 seconds to avoid an error during cron...but I don't want all queries to be given that long of a timeout, so that's a no-go.

    buildOnCommit seems to be working fine in that I'm not seeing errors in the log and the suggester index seems to get updated.

  • πŸ‡©πŸ‡ͺGermany mkalkbrenner πŸ‡©πŸ‡ͺ

    but I don't want all queries to be given that long of a timeout, so that's a no-go.

    This is not correct. Queries use the "query timeout".
    If building the suggester takes 130 seconds, then the "index timeout" has to be raised. Depending on your index' state and the concrete update query, every single update query could cause such a long running query if you "buildOnCommit".
    Especially on large indexes, buildOnCommit behaves really bad. If you configured Solr to commit after 2000 docs, imagine how often the build will happen if you have millions of documents. You only have less than 100k documents and it already takes 130 seconds per build.

    But if you really want to, you can reactivate "buildOnCommit" via custom field configs or by subscribing to a config-set generation event.
    I don't want to reactivate it in the module, not even optional.

    But I agree that we have an issue here, because we might exceed the max cron time. So the solution might be to trigger an asynchronous build and to introduce a config option about its frequency.

  • πŸ‡©πŸ‡ͺGermany mkalkbrenner πŸ‡©πŸ‡ͺ

    I'll try to build such an asynchronous option into Solarium.

  • Status changed to Needs review 6 months ago
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 10.1.x + Environment: PHP 8.2 & MySQL 8
    last update 6 months ago
    31 pass
  • πŸ‡©πŸ‡ͺGermany mkalkbrenner πŸ‡©πŸ‡ͺ

    Here's an experimental patch that leverages the PR for Solarium.

  • Status changed to Fixed 6 months ago
  • πŸ‡©πŸ‡ͺGermany mkalkbrenner πŸ‡©πŸ‡ͺ
  • πŸ‡ΊπŸ‡ΈUnited States mediabounds

    Thanks, mkalkbrenner!

    I "backported" the patch so it applied to the current release of the module 4.3.1, updated Solarium, and disabled buildOnCommit in our index configuration. Cron appears to be working and there are no Solr errors in watchdog; it appears like the suggester is correctly getting rebuilt during cron if content changed since the last cron run.

  • πŸ‡©πŸ‡ͺGermany mkalkbrenner πŸ‡©πŸ‡ͺ

    Thanks for the feedback!

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

  • πŸ‡ΊπŸ‡ΈUnited States AaronBauman Philadelphia

    @mediabounds can you post a patch that applies to 4.3.1?

  • πŸ‡ΊπŸ‡ΈUnited States mediabounds

    @AaronBauman -- absolutely, though I think it would be recommended to update to 4.3.2 of this module which has this issue addressed.

    That being said, attached is the backported patch to apply to 4.3.1.

    In addition to applying the patch, you will need to update the version of solarium to 6.3.5 (while the patch updates the referenced version in composer.json, you probably still need to do the update manually).

    Also for good measure, you may need to go through your exported config and disable buildOnCommit.

  • πŸ‡ΊπŸ‡ΈUnited States AaronBauman Philadelphia

    Thanks for the patch!
    Unfortunately i'm stuck in D9, so updating to latest 4.3.2 is not an option.

  • πŸ‡ΊπŸ‡ΈUnited States neclimdul Houston, TX

    for what its worth, this has likely triggered a bunch of noisy output from cron πŸ› buildAll command output durring cron runs. Active

  • πŸ‡ΊπŸ‡ΈUnited States AaronBauman Philadelphia

    Updated to search_api_solr 4.3.1 and solarium 6.3.5, and applied patch #15
    Suggester is enabled, and buildOnCommit is off

    Still getting the timeout errors in logs, not sure what else to do.

Production build 0.69.0 2024