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

fix permanent lock of sequential command, when an error occurs #402

Merged
merged 1 commit into from
Apr 17, 2024
Merged
Changes from all 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
51 changes: 28 additions & 23 deletions src/Command/SequentialProcessQueueCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,31 +75,36 @@ protected function execute(InputInterface $input, OutputInterface $output)
exit(1);
}

$itemIds = $this->queueService->getAllQueueEntryIds(ImportProcessingService::EXECUTION_TYPE_SEQUENTIAL);
$itemCount = count($itemIds);

$output->writeln("Processing {$itemCount} items sequentially\n");

$progressBar = new ProgressBar($output, $itemCount);
$progressBar->start();

foreach ($itemIds as $i => $id) {
$this->importProcessingService->processQueueItem($id);
$progressBar->advance();

// call the garbage collector to avoid too many connections & memory issue
if (($i + 1) % 200 === 0) {
\Pimcore::collectGarbage();
try {
$itemIds = $this->queueService->getAllQueueEntryIds(ImportProcessingService::EXECUTION_TYPE_SEQUENTIAL);
$itemCount = count($itemIds);

$output->writeln("Processing {$itemCount} items sequentially\n");

$progressBar = new ProgressBar($output, $itemCount);
$progressBar->start();

foreach ($itemIds as $i => $id) {
$this->importProcessingService->processQueueItem($id);
$progressBar->advance();

// call the garbage collector to avoid too many connections & memory issue
if (($i + 1) % 200 === 0) {
\Pimcore::collectGarbage();
}
}

$progressBar->finish();

$this->release(); //release the lock

$output->writeln("\n\nProcessed {$itemCount} items.");

return 0;
} catch (\Throwable $t) {
$this->release();
throw $t;
}

$progressBar->finish();

$this->release(); //release the lock

$output->writeln("\n\nProcessed {$itemCount} items.");

return 0;
}

/**
Expand Down
Loading