Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EZP-32184: Added warning about possible memory leaks for reindex command #138

Merged
merged 5 commits into from
Dec 10, 2020
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 47 additions & 30 deletions eZ/Bundle/EzPublishCoreBundle/Command/ReindexCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/
namespace eZ\Bundle\EzPublishCoreBundle\Command;

use Symfony\Component\Console\Style\SymfonyStyle;
use function count;
use const DIRECTORY_SEPARATOR;
use Doctrine\DBAL\Connection;
Expand Down Expand Up @@ -160,25 +161,25 @@ protected function configure()
'auto'
)->setHelp(
<<<EOT
The command <info>%command.name%</info> indexes the current configured database in the configured search engine index.


Example usage:
- Refresh (add/update) index changes since yesterday:
<comment>ezplatform:reindex --since=yesterday</comment>
See: http://php.net/manual/en/datetime.formats.php

- Refresh (add/update/remove) index on a set of content ID's:
<comment>ezplatform:reindex --content-ids=2,34,68</comment>

- Refresh (add/update) index of a subtree:
<comment>ezplatform:reindex --subtree=45</comment>

- Refresh (add/update) index, disabling the use of child proccesses and initial purging,
and let search engine handle commits using auto commit:
<comment>ezplatform:reindex --no-purge --no-commit --processes=0</comment>

EOT
The command <info>%command.name%</info> indexes the current configured database in the configured search engine index.
Example usage:
- Refresh (add/update) index changes since yesterday:
<comment>ezplatform:reindex --since=yesterday</comment>
See: http://php.net/manual/en/datetime.formats.php
- Refresh (add/update/remove) index on a set of content ID's:
<comment>ezplatform:reindex --content-ids=2,34,68</comment>
- Refresh (add/update) index of a subtree:
<comment>ezplatform:reindex --subtree=45</comment>
- Refresh (add/update) index, disabling the use of child proccesses and initial purging,
and let search engine handle commits using auto commit:
<comment>ezplatform:reindex --no-purge --no-commit --processes=0</comment>
EOT
);
}

Expand All @@ -196,19 +197,35 @@ protected function execute(InputInterface $input, OutputInterface $output): int

if (!$this->searchIndexer instanceof IncrementalIndexer) {
$output->writeln(<<<EOT
DEPRECATED:
Running indexing against an Indexer that has not been updated to use IncrementalIndexer abstract.

Options that won't be taken into account:
- since
- content-ids
- subtree
- processes
- no-purge
EOT
);
DEPRECATED:
Running indexing against an Indexer that has not been updated to use IncrementalIndexer abstract.

Options that won't be taken into account:
- since
- content-ids
- subtree
- processes
- no-purge
EOT);
$this->searchIndexer->createSearchIndex($output, (int) $iterationCount, !$commit);
} else {
$io = new SymfonyStyle($input, $output);
$xdebugState = \extension_loaded('xdebug') ? 'enabled' : 'disabled';
$memoryLimit = ini_get('memory_limit');

$io->warning(<<<EOT
For optimal performance, before running this command, make sure that:
- the xdebug extension is disabled (you have it $xdebugState),
- you're running the command in "prod" environment (default: dev),
- memory limit for big databases is set to "-1" or an adequately high value (your value: $memoryLimit),
- --iteration-count is low enough (default: 50),
- number of processes for parallel batch operations is high enough (default: 'auto' is a good choice).
EOT);

if (!$io->confirm('Continue?', true)) {
return 0;
adamwojs marked this conversation as resolved.
Show resolved Hide resolved
}
konradoboza marked this conversation as resolved.
Show resolved Hide resolved

$output->writeln('Re-indexing started for search engine: ' . $this->searchIndexer->getName());
$output->writeln('');

Expand Down