Search indexer killed by PHP max_execution_time despite sulu_search.indexer_timeout setting
0 reputation · 25 Jul 2021, 09:02 UTC
0 reputation · 25 Jul 2021, 09:02 UTC
On Sulu 2.5 (Symfony 6.x), a full rebuild of the search index via bin/websiteconsole sulu:search:index (or the admin reindex action) is terminated partway through large content trees. The process appears to be stopped by PHP's max_execution_time rather than by any Sulu-level timeout, and no partial-progress or cancellation message is surfaced in the logs.
The relevant snippet in config/packages/sulu_search.yaml is:
sulu_search:
indexer_timeout: 600With this set, I expected the indexer to be allowed up to 600 seconds regardless of the global PHP limit. However, the job still dies at roughly the default execution limit, which suggests the setting is either not applied to the CLI context, not recognized in this Sulu version, or overridden elsewhere.
sulu_search.indexer_timeout actually raise the execution limit for both CLI and admin-triggered indexing, or only one of them?29275 reputation · 25 Jul 2021, 14:44 UTC
sulu_search.indexer_timeout setting does not override the global PHP max_execution_time for all contexts. In Sulu 2.5, this setting is used to call set_time_limit() specifically within the console command. If your PHP CLI environment has a hard limit defined in php.ini, or if you are triggering the index via the Admin UI, the process may be terminated before the Sulu-specific timeout is reached.sulu_search.indexer_timeout is primarily applied to bin/websiteconsole sulu:search:index. It has no effect on indexing triggered through the Sulu Admin interface, which remains strictly bound by the web server's PHP max_execution_time.max_execution_time is set to a non-zero value in php.ini. While set_time_limit() attempts to extend this, certain environment-level restrictions or PHP configurations can prevent the extension.To ensure the indexer completes for large content trees, you must address the execution limit specifically for the CLI environment:
Instead of relying on the Sulu-level setting, override the PHP execution limit for the command execution itself. You can do this by passing the environment variable when running the command:
PHP_MAX_EXECUTION=0 php bin/websiteconsole sulu:search:index
Alternatively, ensure your CLI php.ini has max_execution_time = 0 (which means infinite for the CLI only).
For large datasets, avoid using the Admin UI for full reindexes. Use the CLI via a process manager like supervisor or a systemd service to ensure the process is not tied to a browser-session timeout.
To verify if your CLI is respecting the limits, run the following command and check the active limit value:
php -i | grep max_execution_time
Are you triggering the reindex via the command line or the Sulu Admin interface? (If it is the Admin UI, the sulu_search.indexer_timeout setting is effectively ignored.)
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.